aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-08-07 08:21:56 +0000
committerZac Medico <zmedico@gentoo.org>2009-08-07 08:21:56 +0000
commit40932fc85440f9fd5952829913c327ad3bfee722 (patch)
tree8c28ebe4cdec9693ebded8066f15b060c948d66b /pym/portage/process.py
parentIn getconfig(), specify utf_8 encoding for py3k. (diff)
downloadportage-40932fc85440f9fd5952829913c327ad3bfee722.tar.gz
portage-40932fc85440f9fd5952829913c327ad3bfee722.tar.bz2
portage-40932fc85440f9fd5952829913c327ad3bfee722.zip
Make spawn decode unicode in order to avoid a potential UnicodeEncodeError
from os.execve(). svn path=/main/trunk/; revision=13944
Diffstat (limited to 'pym/portage/process.py')
-rw-r--r--pym/portage/process.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/pym/portage/process.py b/pym/portage/process.py
index a88f5bf28..051a59f61 100644
--- a/pym/portage/process.py
+++ b/pym/portage/process.py
@@ -178,6 +178,17 @@ 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.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 = 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.
binary = mycommand[0]