[Python-checkins] Clear possible exception before calling PyTuple_Pack in IMPORT_NAME (GH-6033)

Xiang Zhang webhook-mailer at python.org
Thu Mar 8 21:22:04 EST 2018


https://github.com/python/cpython/commit/34bb88dc5bc447832db8c7ccdc173311e0685eab
commit: 34bb88dc5bc447832db8c7ccdc173311e0685eab
branch: 2.7
author: Xiang Zhang <angwerzx at 126.com>
committer: GitHub <noreply at github.com>
date: 2018年03月09日T10:21:58+08:00
summary:
Clear possible exception before calling PyTuple_Pack in IMPORT_NAME (GH-6033)
files:
M Python/ceval.c
diff --git a/Python/ceval.c b/Python/ceval.c
index bae158dc1402..b55b4d66880c 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,


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /