summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-06-13 21:51:27 (GMT)
committerGuido van Rossum <guido@python.org>2007-06-13 21:51:27 (GMT)
commit67aca9e04e5360007c46fde3d64debb4dad4d9ff (patch)
treee2ecd4ca63ea1c1d1e42acdb182f532f2b4b7621 /Lib/os.py
parentcd16bf640405065e4702539632ce577536207d88 (diff)
downloadcpython-67aca9e04e5360007c46fde3d64debb4dad4d9ff.zip
cpython-67aca9e04e5360007c46fde3d64debb4dad4d9ff.tar.gz
cpython-67aca9e04e5360007c46fde3d64debb4dad4d9ff.tar.bz2
Following an idea by Ron Adam, make sure keys and values in the
environ dict are strings (in particular, not 8-bit strings).
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/os.py b/Lib/os.py
index e47ec99..2987cfc 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -420,12 +420,12 @@ else:
self.unsetenv = unsetenv
self.data = data = {}
for key, value in environ.items():
- data[keymap(key)] = value
+ data[keymap(key)] = str(value)
def __getitem__(self, key):
return self.data[self.keymap(key)]
- def __setitem__(self, key, item):
- self.putenv(key, item)
- self.data[self.keymap(key)] = item
+ def __setitem__(self, key, value):
+ self.putenv(key, str(value))
+ self.data[self.keymap(key)] = str(value)
def __delitem__(self, key):
self.unsetenv(key)
del self.data[self.keymap(key)]
@@ -438,7 +438,7 @@ else:
return dict(self)
def setdefault(self, key, value):
if key not in self:
- self[key] = value
+ self[key] = str(value)
return self[key]
try:
@@ -456,9 +456,9 @@ else:
__all__.append("unsetenv")
if name in ('os2', 'nt'): # Where Env Var Names Must Be UPPERCASE
- _keymap = lambda key: key.upper()
+ _keymap = lambda key: str(key.upper())
else: # Where Env Var Names Can Be Mixed Case
- _keymap = lambda key: key
+ _keymap = lambda key: str(key)
environ = _Environ(environ, _keymap, _putenv, _unsetenv)