Message360788
Supporting __fspath__ for os.environ[b] makes it consistent with POSIX os.putenv, which already supports it via PyUnicode_FSConverter. For example:
os.putenv(Path('spam'), Path('eggs'))
getenv = ctypes.CDLL('libc.so.6').getenv
getenv.restype = ctypes.c_char_p
>>> getenv(b'spam')
b'eggs'
For symmetry, os.putenv in Windows could be updated to support __fspath__. An old patch for bpo-28188 implements this, along with bytes support, via PyUnicode_FSDecoder. But bytes support would be limited to UTF-8 strings, so it wouldn't be as flexible as os.environb in POSIX, which supports arbitrary bytes except for embedded nulls. |
|
Date |
User |
Action |
Args |
2020-01-27 18:45:46 | eryksun | set | recipients:
+ eryksun, brett.cannon, vstinner, ethan.furman, serhiy.storchaka, Antony.Lee |
2020-01-27 18:45:46 | eryksun | set | messageid: <1580150746.76.0.624120022932.issue39461@roundup.psfhosted.org> |
2020-01-27 18:45:46 | eryksun | link | issue39461 messages |
2020-01-27 18:45:46 | eryksun | create | |
|