mirror of https://github.com/python/cpython.git
Support case insensitive treatment of os.environ keys on Windows and
DOS (as well as OS/2). I presume that making a call to putenv() with a lowercase key will actually do the right thing. I know this is so on Windows/DOS, and I expect it is so OS/2 -- but the old OS/2 code didn't assume this. (I don't know if the person who provided the OS/2 patch was clueless or just didn't care about DOS and Windows.) Also ripped out the support for pickling -- as of 1.5, this is no longer needed to make pickling work.
This commit is contained in:
parent
7f875ef749
commit
da4d6daa4a
15
Lib/os.py
15
Lib/os.py
|
@ -226,15 +226,19 @@ def _execvpe(file, args, env = None):
|
|||
else:
|
||||
import UserDict
|
||||
|
||||
if name in ('os2', ): # Where Env Var Names Must Be UPPERCASE
|
||||
if name in ('os2', 'nt', 'dos'): # Where Env Var Names Must Be UPPERCASE
|
||||
# But we store them as upper case
|
||||
import string
|
||||
class _Environ(UserDict.UserDict):
|
||||
def __init__(self, environ):
|
||||
UserDict.UserDict.__init__(self)
|
||||
self.data = environ
|
||||
data = self.data
|
||||
upper = string.upper
|
||||
for k, v in environ.items():
|
||||
data[upper(k)] = v
|
||||
def __setitem__(self, key, item):
|
||||
key = string.upper(key)
|
||||
putenv(key, item)
|
||||
key = string.upper(key)
|
||||
self.data[key] = item
|
||||
def __getitem__(self, key):
|
||||
return self.data[string.upper(key)]
|
||||
|
@ -244,13 +248,8 @@ class _Environ(UserDict.UserDict):
|
|||
def __init__(self, environ):
|
||||
UserDict.UserDict.__init__(self)
|
||||
self.data = environ
|
||||
def __getinitargs__(self):
|
||||
import copy
|
||||
return (copy.copy(self.data),)
|
||||
def __setitem__(self, key, item):
|
||||
putenv(key, item)
|
||||
self.data[key] = item
|
||||
def __copy__(self):
|
||||
return _Environ(self.data.copy())
|
||||
|
||||
environ = _Environ(environ)
|
||||
|
|
Loading…
Reference in New Issue