Issue #8391: os.execvpe() and os.getenv() supports unicode with surrogates and

bytes strings for environment keys and values
This commit is contained in:
Victor Stinner 2010-04-23 21:41:56 +00:00
parent 534db4e19f
commit 13bb71c38f
5 changed files with 123 additions and 169 deletions

View file

@ -1090,7 +1090,10 @@ class Popen(object):
fs_encoding = sys.getfilesystemencoding()
def fs_encode(s):
"""Encode s for use in the env, fs or cmdline."""
return s.encode(fs_encoding, 'surrogateescape')
if isinstance(s, bytes):
return s
else:
return s.encode(fs_encoding, 'surrogateescape')
# We must avoid complex work that could involve
# malloc or free in the child process to avoid