mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
(Merge 3.3) Close #17702: os.environ now raises KeyError with the original
environment variable name (str on UNIX), instead of using the encoded name (bytes on UNIX).
This commit is contained in:
commit
43aa0d07e2
3 changed files with 34 additions and 4 deletions
|
@ -632,6 +632,24 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
|
|||
key = 'key='
|
||||
self.assertRaises(OSError, os.environ.__delitem__, key)
|
||||
|
||||
def test_key_type(self):
|
||||
missing = 'missingkey'
|
||||
self.assertNotIn(missing, os.environ)
|
||||
|
||||
try:
|
||||
os.environ[missing]
|
||||
except KeyError as err:
|
||||
self.assertIs(err.args[0], missing)
|
||||
else:
|
||||
self.fail("KeyError not raised")
|
||||
|
||||
try:
|
||||
del os.environ[missing]
|
||||
except KeyError as err:
|
||||
self.assertIs(err.args[0], missing)
|
||||
else:
|
||||
self.fail("KeyError not raised")
|
||||
|
||||
class WalkTests(unittest.TestCase):
|
||||
"""Tests for os.walk()."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue