summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-11-05 12:55:20 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-11-05 12:55:20 (GMT)
commit60a1d3cd152e9340727409ee48372a7cbc31a16f (patch)
tree954863451144085e18cb0a65bb4c146849dfe730
parent4d11a94fb66ecf4d1f12d0f314d9e1f6dc3e756a (diff)
downloadcpython-60a1d3cd152e9340727409ee48372a7cbc31a16f.zip
cpython-60a1d3cd152e9340727409ee48372a7cbc31a16f.tar.gz
cpython-60a1d3cd152e9340727409ee48372a7cbc31a16f.tar.bz2
Issue #25556: Fix LOAD_GLOBAL bytecode when globals type is not dict and the
requested name doesn't exist in globals: clear the KeyError exception before calling PyObject_GetItem(). Fail also if the raised exception is not a KeyError.
-rw-r--r--Python/ceval.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index f9e8ef8..beabfeb 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2363,6 +2363,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
/* Slow-path if globals or builtins is not a dict */
v = PyObject_GetItem(f->f_globals, name);
if (v == NULL) {
+ if (!PyErr_ExceptionMatches(PyExc_KeyError))
+ goto error;
+ PyErr_Clear();
+
v = PyObject_GetItem(f->f_builtins, name);
if (v == NULL) {
if (PyErr_ExceptionMatches(PyExc_KeyError))