[Python-bugs-list] Bug in os.environ for Windows (PR#50)
bobalex@uppercase.xerox.com
bobalex@uppercase.xerox.com
Wed, 11 Aug 1999 19:19:18 -0400 (EDT)
Full_Name: Bob Alexander
Version: 1.5.2
OS: WinNT
Submission from: cfwww2.epn.eastgw.xerox.com (208.140.33.202)
os.environ for Windows appears to be a map-type object that converts its keys to
upper case. Retrieval using a mixed case key works in some cases, but some
overloaded "operators" don't seem to do the right thing unless I pass an
all-upper-case key. E.g.:
>>> os.environ["x"] = "y" # Stores pair {"X": "y"}
>>> os.environ["x"] # Works, indicates an effort is made
'y' # to retrieve mixed case keys
>>> os.environ.get("x", "NOT FOUND") # Doesn't see the key "x"
'NOT FOUND'
>>> os.environ.get("X", "NOT FOUND") # Works with all-upper-case key
'y'
>>> del os.environ["x"] # Doesn't see the key "x"
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "E:\Program Files\Python\Lib\UserDict.py", line 16, in __delitem__
def __delitem__(self, key): del self.data[key]
KeyError: x
>>> del os.environ["X"] # Works with all-upper-case key