mirror of
https://github.com/python/cpython.git
synced 2025-07-13 22:35:18 +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
|
@ -450,6 +450,8 @@ environ = _Environ(environ, _keymap, _putenv, _unsetenv)
|
|||
def getenv(key, default=None):
|
||||
"""Get an environment variable, return None if it doesn't exist.
|
||||
The optional second argument can specify an alternate default."""
|
||||
if isinstance(key, bytes):
|
||||
key = key.decode(sys.getfilesystemencoding(), "surrogateescape")
|
||||
return environ.get(key, default)
|
||||
__all__.append("getenv")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue