From: Xiang Zhang Date: Fri, 9 Mar 2018 02:21:58 +0000 (+0800) Subject: Clear possible exception before calling PyTuple_Pack in IMPORT_NAME (GH-6033) X-Git-Tag: v2.7.15rc1~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=34bb88dc5bc447832db8c7ccdc173311e0685eab;p=python Clear possible exception before calling PyTuple_Pack in IMPORT_NAME (GH-6033) --- diff --git a/Python/ceval.c b/Python/ceval.c index bae158dc14..b55b4d6688 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2598,6 +2598,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) TARGET(IMPORT_NAME) { + long res; w = GETITEM(names, oparg); x = PyDict_GetItemString(f->f_builtins, "__import__"); if (x == NULL) { @@ -2608,7 +2609,12 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) Py_INCREF(x); v = POP(); u = TOP(); - if (PyInt_AsLong(u) != -1 || PyErr_Occurred()) + res = PyInt_AsLong(u); + if (res != -1 || PyErr_Occurred()) { + if (res == -1) { + assert(PyErr_Occurred()); + PyErr_Clear(); + } w = PyTuple_Pack(5, w, f->f_globals, @@ -2616,6 +2622,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) Py_None : f->f_locals, v, u); + } else w = PyTuple_Pack(4, w,