Eryk Sun <eryk...@gmail.com> added the comment:

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.

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue15373>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to