summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/os.py4
-rw-r--r--Lib/test/test_os.py3
2 files changed, 5 insertions, 2 deletions
diff --git a/Lib/os.py b/Lib/os.py
index 96720e4..5fde360 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -648,7 +648,7 @@ class _Environ(MutableMapping):
value = self._data[self.encodekey(key)]
except KeyError:
# raise KeyError with the original key value
- raise KeyError(key)
+ raise KeyError(key) from None
return self.decodevalue(value)
def __setitem__(self, key, value):
@@ -664,7 +664,7 @@ class _Environ(MutableMapping):
del self._data[encodedkey]
except KeyError:
# raise KeyError with the original key value
- raise KeyError(key)
+ raise KeyError(key) from None
def __iter__(self):
for key in self._data:
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index b7796b5..a4be0bb 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -646,10 +646,13 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol):
with self.assertRaises(KeyError) as cm:
os.environ[missing]
self.assertIs(cm.exception.args[0], missing)
+ self.assertTrue(cm.exception.__suppress_context__)
with self.assertRaises(KeyError) as cm:
del os.environ[missing]
self.assertIs(cm.exception.args[0], missing)
+ self.assertTrue(cm.exception.__suppress_context__)
+
class WalkTests(unittest.TestCase):
"""Tests for os.walk()."""