jason-kane/PyYapf

PyYapf.py subprocess popen TypeError: environment can only contain strings

Closed this issue · 2 comments

I had to make the following change to PyYapf.py line 169 because the encoding is unicode (u'UTF-8' in my case). This is for Sublime Text 2 version 2.02, Windows 7.


@@ -166,7 +166,7 @@
 
         # specify encoding in environment
         self.popen_env = os.environ.copy()
-        self.popen_env['LANG'] = self.encoding
+        self.popen_env['LANG'] = str(self.encoding)
 
         # win32: hide console window
         if sys.platform in ('win32', 'cygwin'):

merged

What a "meta" encoding bug. 😄

PS: The change is a bit subtle, since str behaves differently on Python 2/3. Thankfully, so does Popen.