[Python-checkins] cpython (merge 3.3 -> default): (Merge 3.3) Close #17702: On error, os.environb now removes suppress the except
victor.stinner
python-checkins at python.org
Fri Aug 23 19:24:50 CEST 2013
http://hg.python.org/cpython/rev/01f33959ddf6
changeset: 85343:01f33959ddf6
parent: 85341:761174766482
parent: 85342:26c049dc1a4a
user: Victor Stinner <victor.stinner at gmail.com>
date: Fri Aug 23 19:23:42 2013 +0200
summary:
(Merge 3.3) Close #17702: On error, os.environb now removes suppress the except
context when raising a new KeyError with the original key.
files:
Lib/os.py | 4 ++--
Lib/test/test_os.py | 3 +++
Misc/NEWS | 3 +++
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/Lib/os.py b/Lib/os.py
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -648,7 +648,7 @@
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 @@
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
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -646,10 +646,13 @@
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()."""
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -38,6 +38,9 @@
Library
-------
+- Issue #17702: On error, os.environb now removes suppress the except context
+ when raising a new KeyError with the original key.
+
- Issue #16809: Fixed some tkinter incompabilities with Tcl/Tk 8.6.
- Issue #16809: Tkinter's splitlist() and split() methods now accept Tcl_Obj
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list