This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients Antony.Lee, brett.cannon, eryksun, ethan.furman, serhiy.storchaka, vstinner
Date 2020-01-27.18:45:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580150746.76.0.624120022932.issue39461@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-01-27 18:45:46eryksunsetrecipients: + eryksun, brett.cannon, vstinner, ethan.furman, serhiy.storchaka, Antony.Lee
2020-01-27 18:45:46eryksunsetmessageid: <1580150746.76.0.624120022932.issue39461@roundup.psfhosted.org>
2020-01-27 18:45:46eryksunlinkissue39461 messages
2020-01-27 18:45:46eryksuncreate