summaryrefslogtreecommitdiffstats
path: root/pym/portage/process.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-21 20:12:40 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-21 20:12:40 +0000
commita42108e7b69ceb3b82ab2c8497eca70c0db59040 (patch)
treea00d54cbeb86d82ca0824e5175fcd613c92127ef /pym/portage/process.py
parentff3e65edee5959cd95f2268d7755d83a8f4a0d66 (diff)
downloadportage-a42108e7b69ceb3b82ab2c8497eca70c0db59040.tar.gz
portage-a42108e7b69ceb3b82ab2c8497eca70c0db59040.tar.bz2
portage-a42108e7b69ceb3b82ab2c8497eca70c0db59040.zip
Don't encode the env in py3k since it expects strings for the env that's
passed into os.execve(). svn path=/main/trunk/; revision=14363
Diffstat (limited to 'pym/portage/process.py')
-rw-r--r--pym/portage/process.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/pym/portage/process.py b/pym/portage/process.py
index 428c66f4c..68c523a09 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -188,13 +188,14 @@ def spawn(mycommand, env={}, opt_name=None, fd_pipes=None, returnpid=False,
if isinstance(mycommand, basestring):
mycommand = mycommand.split()
- # Avoid a potential UnicodeEncodeError from os.execve().
- env_bytes = {}
- for k, v in env.items():
- env_bytes[_unicode_encode(k, encoding=_encodings['content'])] = \
- _unicode_encode(v, encoding=_encodings['content'])
- env = env_bytes
- del env_bytes
+ if sys.hexversion < 0x3000000:
+ # Avoid a potential UnicodeEncodeError from os.execve().
+ env_bytes = {}
+ for k, v in env.items():
+ env_bytes[_unicode_encode(k, encoding=_encodings['content'])] = \
+ _unicode_encode(v, encoding=_encodings['content'])
+ env = env_bytes
+ del env_bytes
# If an absolute path to an executable file isn't given
# search for it unless we've been told not to.
@@ -373,13 +374,8 @@ def _exec(binary, mycommand, opt_name, fd_pipes, env, gid, groups, uid, umask,
if pre_exec:
pre_exec()
- # Decode all keys for compatibility with Python 3.
- env_decoded = {}
- for k, v in env.items():
- env_decoded[_unicode_decode(k)] = v
-
# And switch to the new process.
- os.execve(binary, myargs, env_decoded)
+ os.execve(binary, myargs, env)
def find_binary(binary):
"""