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 andrei.avk, eryksun, gregory.p.smith, htgoebel, josh.r, kamilturek, methane, mkatsev, pitrou, r.david.murray, rhettinger, rmast, sblondon, serhiy.storchaka
Date 2022-03-02.00:42:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646181721.65.0.048491420649.issue15373@roundup.psfhosted.org>
In-reply-to
Content
In bpo-28824, I suggested preserving the case of environment variables in Windows by using a case-insensitive subclass of str in the encodekey() function. This is self-contained by the use of the encodekey() and decodekey() functions in the mapping methods such as __iter__(). The reason for this is mostly about aesthetics, but also about faithfully displaying the actual environment variable names. Opinions vary, but to me "WindowsSdkVerBinPath" is both easier on my eyes and easier to read than "WINDOWSSDKVERBINPATH". The eyesore factor gets amplified when it's a wall of all upper-cased names 'screaming' at me.

A copy via dict(os.environ) would use regular str keys and lose the case-insensitive, case-preserving property. It would be more useful if os.environ.copy() were implemented to return a copy that keeps the case-insensitive property for keys but disables updating the process environment. This could be implemented by making putenv and unsetenv parameters in the constructor. If self.putenv or self.unsetenv is None, then __setitem__() or __delitem__() woud have no effect on the process environment. The copy() method would return a new _Environ instance for self._data.copy(), one which of course disables updating the process environment.
History
Date User Action Args
2022-03-02 00:42:01eryksunsetrecipients: + eryksun, rhettinger, gregory.p.smith, htgoebel, pitrou, r.david.murray, methane, serhiy.storchaka, josh.r, sblondon, andrei.avk, kamilturek, rmast, mkatsev
2022-03-02 00:42:01eryksunsetmessageid: <1646181721.65.0.048491420649.issue15373@roundup.psfhosted.org>
2022-03-02 00:42:01eryksunlinkissue15373 messages
2022-03-02 00:42:01eryksuncreate