Update import to import portage.os (with unicode wrappers), and use
authorZac Medico <zmedico@gentoo.org>
Sat, 15 Aug 2009 07:23:51 +0000 (07:23 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 15 Aug 2009 07:23:51 +0000 (07:23 -0000)
_unicode_encode() and _content_encoding for encoding unicode env
vars in spawn().

svn path=/main/trunk/; revision=14062

pym/portage/process.py

index 5dcf481e2c437dce936dbb90965cb53305423357..1b584688387a79be14b74d52ba0c19e5047037da 100644 (file)
@@ -4,12 +4,14 @@
 # $Id$
 
 
-import os
 import atexit
 import signal
 import sys
 import traceback
 
+from portage import os
+from portage import _content_encoding
+from portage import _unicode_encode
 import portage
 portage.proxy.lazyimport.lazyimport(globals(),
        'portage.util:dump_traceback',
@@ -182,11 +184,8 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
        # Avoid a potential UnicodeEncodeError from os.execve().
        env_bytes = {}
        for k, v in env.iteritems():
-               if isinstance(k, unicode):
-                       k = k.encode('utf_8', 'replace')
-               if isinstance(v, unicode):
-                       v = v.encode('utf_8', 'replace')
-               env_bytes[k] = v
+               env_bytes[_unicode_encode(k, encoding=_content_encoding)] = \
+                       _unicode_encode(v, encoding=_content_encoding)
        env = env_bytes
        del env_bytes