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

STINNER Victor report at bugs.python.org
Mon Jan 27 15:41:44 EST 2020


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

> I don't think this should be done (and I honestly would have disagreed with the Popen change for its 'env' argument or any other place that is dealing with environment variables). Environment variables are strings, period, so they should be specified as such; explicit is better than implicit (and there isn't enough pragmatic benefit to override this in my opinion).

I don't think that subprocess accepts fspath on purpose. It uses fsencode() because it's convenient to encode Unicode to the filesystem encoding using the right error handler.

It's a side effect of the commit c1cbeedf0c650c3f7c64f04479070d39e15e1baf. In fact, I'm opposed to this commit, but now it's too change to change it again :-)

os.putenv() is unrelated to os.environ. Calling os.putenv() does not update os.environ, whereas setting a key in os.environ calls internally os.putenv().

I like the idea of keeping os.environ as simple as a dict mapping strings to trings (in term of API, internally it's more complicated).

----------

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


More information about the Python-bugs-list mailing list