[issue13890] test_importlib failures under Windows
Antoine Pitrou
report at bugs.python.org
Fri Jan 27 22:42:48 CET 2012
Antoine Pitrou <pitrou at free.fr> added the comment:
Well apparently nt.environ doesn't reflect os.environ:
>>> os.environ['PYTHONCASEOK'] = '1'
>>> nt.environ['PYTHONCASEOK']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 'PYTHONCASEOK'
>>> nt.environ[b'PYTHONCASEOK']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: b'PYTHONCASEOK'
>>> os.environ['PYTHONCASEOK']
'1'
>>> os.environ[b'PYTHONCASEOK']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\t\cpython\lib\os.py", line 450, in __getitem__
value = self._data[self.encodekey(key)]
File "C:\t\cpython\lib\os.py", line 508, in encodekey
return encode(key).upper()
File "C:\t\cpython\lib\os.py", line 503, in check_str
raise TypeError("str expected, not %s" % type(value).__name__)
TypeError: str expected, not bytes
This is silly and is because of how the environ mapping is implemented in Lib/os.py: under POXIX, os.environ reflects posix.environ (it uses the same underlying dict), while under Windows, os.environ uses a distinct dict from nt.environ.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13890>
_______________________________________
More information about the Python-bugs-list
mailing list