From a42108e7b69ceb3b82ab2c8497eca70c0db59040 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 21 Sep 2009 20:12:40 +0000 Subject: [PATCH] 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 --- pym/portage/process.py | 22 +++++++++------------- 1 file 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): """ -- 2.26.2