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

Skip to content

Commit 34bb88d

Browse files
authored
Clear possible exception before calling PyTuple_Pack in IMPORT_NAME (pythonGH-6033)
1 parent 55d5bfb commit 34bb88d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Python/ceval.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2598,6 +2598,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
25982598

25992599
TARGET(IMPORT_NAME)
26002600
{
2601+
long res;
26012602
w = GETITEM(names, oparg);
26022603
x = PyDict_GetItemString(f->f_builtins, "__import__");
26032604
if (x == NULL) {
@@ -2608,14 +2609,20 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
26082609
Py_INCREF(x);
26092610
v = POP();
26102611
u = TOP();
2611-
if (PyInt_AsLong(u) != -1 || PyErr_Occurred())
2612+
res = PyInt_AsLong(u);
2613+
if (res != -1 || PyErr_Occurred()) {
2614+
if (res == -1) {
2615+
assert(PyErr_Occurred());
2616+
PyErr_Clear();
2617+
}
26122618
w = PyTuple_Pack(5,
26132619
w,
26142620
f->f_globals,
26152621
f->f_locals == NULL ?
26162622
Py_None : f->f_locals,
26172623
v,
26182624
u);
2625+
}
26192626
else
26202627
w = PyTuple_Pack(4,
26212628
w,

0 commit comments

Comments
 (0)