summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-07-03 20:17:46 (GMT)
committerAntoine Pitrou <pitrou@free.fr>2018-07-03 20:17:46 (GMT)
commite1ebf51f76037b7e02711aaeb9bf66c9147f4c74 (patch)
tree0b3a3e62b437582437089205a9073c2c5ac2bcf2 /Python/pythonrun.c
parentf55a818954212e8e6c97e3d66cf1478120a3220f (diff)
downloadcpython-e1ebf51f76037b7e02711aaeb9bf66c9147f4c74.zip
cpython-e1ebf51f76037b7e02711aaeb9bf66c9147f4c74.tar.gz
cpython-e1ebf51f76037b7e02711aaeb9bf66c9147f4c74.tar.bz2
bpo-24596: Decref module in PyRun_SimpleFileExFlags() on SystemExit (GH-7918) (GH-8069)
PyErr_Print() will not return when the exception is a SystemExit, so decref the __main__ module object in that case. (cherry picked from commit d8cba5d16f1333fd625726fc72e66afbd45b8d00) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index b23cfda..7db7052 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -421,6 +421,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
}
flush_io();
if (v == NULL) {
+ Py_CLEAR(m);
PyErr_Print();
goto done;
}
@@ -429,7 +430,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;
}