[Python-checkins] cpython: use error label instead of breaking eval loop (closes #16693)
benjamin.peterson
python-checkins at python.org
Sat Dec 15 18:51:18 CET 2012
http://hg.python.org/cpython/rev/bb6fd6f021e7
changeset: 80857:bb6fd6f021e7
user: Benjamin Peterson <benjamin at python.org>
date: Sat Dec 15 12:51:05 2012 -0500
summary:
use error label instead of breaking eval loop (closes #16693)
files:
Lib/test/test_builtin.py | 5 +++++
Python/ceval.c | 5 ++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -462,6 +462,11 @@
self.assertRaises(TypeError, eval, ())
self.assertRaises(SyntaxError, eval, bom[:2] + b'a')
+ class X:
+ def __getitem__(self, key):
+ raise ValueError
+ self.assertRaises(ValueError, eval, "foo", {}, X())
+
def test_general_eval(self):
# Tests that general mappings can be used for the locals argument
diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2162,9 +2162,8 @@
else {
v = PyObject_GetItem(locals, name);
if (v == NULL && PyErr_Occurred()) {
- if (!PyErr_ExceptionMatches(
- PyExc_KeyError))
- break;
+ if (!PyErr_ExceptionMatches(PyExc_KeyError))
+ goto error;
PyErr_Clear();
}
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list