[issue39461] [RFE] os.environ should support Path-like values, like subprocess(..., env=...)

STINNER Victor report at bugs.python.org
Tue Jan 28 20:55:41 EST 2020


STINNER Victor <vstinner at python.org> added the comment:

I understand that os.fsencode() was modified to support the fspath protocol to be consistent with the C implementation PyUnicode_FSConverter() which calls PyOS_FSPath().

I agree that at least in C, we need two functions: one which accepts (str, bytes), another which also supports the fspath protocol.

IMHO PyUnicode_FSConverter() was modified to support fspath because it was convenient to only modify one function. But this change wasn't designed to decide in each function if fspath should be accepted or not.

For me, os.putenv() should not accept fspath neither.

This issue is not specific to os.environ. It's more general about the PEP 519 implementation. IMHO the implementation should be "adjusted".

I like the deprecation idea ;-) We did something similar with functions accepting float by mistake. First a deprecation warning was emited, and then it became a hard error (exception).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39461>
_______________________________________


More information about the Python-bugs-list mailing list