mirror of
https://github.com/python/cpython.git
synced 2025-07-14 06:45:17 +00:00
Issue #8391: os.execvpe() and os.getenv() supports unicode with surrogates and
bytes strings for environment keys and values
This commit is contained in:
parent
534db4e19f
commit
13bb71c38f
5 changed files with 123 additions and 169 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue