From: Benjamin Peterson Date: Sat, 15 Dec 2012 17:51:05 +0000 (-0500) Subject: use error label instead of breaking eval loop (closes #16693) X-Git-Tag: v3.4.0a1~1852^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9272279afdd5f102f0f1d4022da61265c5a46d04;p=thirdparty%2FPython%2Fcpython.git use error label instead of breaking eval loop (closes #16693) --- diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 19d7c7068d3c..2c5201e84937 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -462,6 +462,11 @@ class BuiltinTest(unittest.TestCase): 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 index 807fa7d2c3b6..32c203ecbcf0 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2162,9 +2162,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) 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(); } }