]> granicus.if.org Git - python/commitdiff
Support case insensitive treatment of os.environ keys on Windows and
authorGuido van Rossum <guido@python.org>
Tue, 4 Aug 1998 16:01:23 +0000 (16:01 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 4 Aug 1998 16:01:23 +0000 (16:01 +0000)
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

index 03f6ae24b32710f0bdff79a0a92e07172b66ac9e..28ed3cfff1e858c21fcf31d6d655224f957a7faf 100644 (file)
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -226,15 +226,19 @@ except NameError:
 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 @@ else:
             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)