Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c48e81e

Browse files
committed
Merge
2 parents 3454339 + 9272279 commit c48e81e

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

Lib/test/test_builtin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,11 @@ def test_eval(self):
462462
self.assertRaises(TypeError, eval, ())
463463
self.assertRaises(SyntaxError, eval, bom[:2] + b'a')
464464

465+
class X:
466+
def __getitem__(self, key):
467+
raise ValueError
468+
self.assertRaises(ValueError, eval, "foo", {}, X())
469+
465470
def test_general_eval(self):
466471
# Tests that general mappings can be used for the locals argument
467472

Python/ceval.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,9 +2162,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
21622162
else {
21632163
v = PyObject_GetItem(locals, name);
21642164
if (v == NULL && PyErr_Occurred()) {
2165-
if (!PyErr_ExceptionMatches(
2166-
PyExc_KeyError))
2167-
break;
2165+
if (!PyErr_ExceptionMatches(PyExc_KeyError))
2166+
goto error;
21682167
PyErr_Clear();
21692168
}
21702169
}

0 commit comments

Comments
 (0)