summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/Lib/os.py b/Lib/os.py
index 5f35f4c..12d80ee 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -644,7 +644,11 @@ class _Environ(MutableMapping):
self._data = data
def __getitem__(self, key):
- value = self._data[self.encodekey(key)]
+ try:
+ value = self._data[self.encodekey(key)]
+ except KeyError:
+ # raise KeyError with the original key value
+ raise KeyError(key)
return self.decodevalue(value)
def __setitem__(self, key, value):
@@ -654,9 +658,13 @@ class _Environ(MutableMapping):
self._data[key] = value
def __delitem__(self, key):
- key = self.encodekey(key)
- self.unsetenv(key)
- del self._data[key]
+ encodedkey = self.encodekey(key)
+ self.unsetenv(encodedkey)
+ try:
+ del self._data[encodedkey]
+ except KeyError:
+ # raise KeyError with the original key value
+ raise KeyError(key)
def __iter__(self):
for key in self._data: