mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
c4e0d982f3
commit
6d10139d70
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