Commit db81953f authored by Benjamin Peterson's avatar Benjamin Peterson

use error label instead of breaking eval loop (closes #16693)

parent 5cb3c804
......@@ -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
......
......@@ -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();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment