Close #17702: On error, os.environb now removes suppress the except context

when raising a new KeyError with the original key.
This commit is contained in:
Victor Stinner 2013-08-23 19:19:15 +02:00
parent f1e0273023
commit 0c2dd0c0a9
3 changed files with 8 additions and 2 deletions

View file

@ -673,7 +673,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):
@ -689,7 +689,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: