From da4d6daa4a4a95f7031f9b8c3e76222ec4fd509e Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Aug 1998 16:01:23 +0000 Subject: [PATCH] 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. --- Lib/os.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Lib/os.py b/Lib/os.py index 03f6ae24b32..28ed3cfff1e 100644 --- a/Lib/os.py +++ b/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)