[issue39461] [RFE] os.environ should support Path-like values, like subprocess(..., env=...)
Eryk Sun
report at bugs.python.org
Mon Jan 27 16:22:53 EST 2020
Eryk Sun <eryksun at gmail.com> added the comment:
> I honestly would have disagreed with the Popen change for its 'env'
> argument or any other place that is dealing with environment
> variables
os.spawnve (Windows) and os.execve support __fspath__ for the env dict partially due to me (bpo-28114), so sorry if that was the wrong decision. However, at least on the POSIX side, I was restoring previous behavior that aligned with POSIX os.putenv. An example of what's supported currently:
Windows:
>>> path = os.environ['comspec']
>>> argv = ['cmd', '/c', 'echo %SPAM%']
>>> env = os.environ.copy()
>>> env[Path('SPAM')] = Path('eggs')
>>> os.spawnve(0, path, argv, env)
eggs
0
POSIX:
>>> path = '/bin/bash'
>>> argv = ['bash', '-c', 'echo $SPAM']
>>> env = os.environ.copy()
>>> env[Path('SPAM')] = Path('eggs')
>>> os.spawnve(0, path, argv, env)
eggs
0
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39461>
_______________________________________
More information about the Python-bugs-list
mailing list