bpo-24596: Decref module in PyRun_SimpleFileExFlags() on SystemExit (GH-7918)
PyErr_Print() will not return when the exception is a SystemExit, so decref the __main__ module object in that case.
This commit is contained in:
committed by
Antoine Pitrou
parent
831c29721d
commit
d8cba5d16f
@@ -431,6 +431,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
|
||||
}
|
||||
flush_io();
|
||||
if (v == NULL) {
|
||||
Py_CLEAR(m);
|
||||
PyErr_Print();
|
||||
goto done;
|
||||
}
|
||||
@@ -439,7 +440,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
|
||||
done:
|
||||
if (set_file_name && PyDict_DelItemString(d, "__file__"))
|
||||
PyErr_Clear();
|
||||
Py_DECREF(m);
|
||||
Py_XDECREF(m);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user