diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-07-03 20:13:28 (GMT) |
---|---|---|
committer | Antoine Pitrou <pitrou@free.fr> | 2018-07-03 20:13:28 (GMT) |
commit | 20ae4c60258479a0732d12af292f422679444e2c (patch) | |
tree | f9c070334afe70acf494a4258f4dec21cfe212a4 /Python/pythonrun.c | |
parent | 6699386231d326c50439b9e1df752e1aed7ca6b4 (diff) | |
download | cpython-20ae4c60258479a0732d12af292f422679444e2c.zip cpython-20ae4c60258479a0732d12af292f422679444e2c.tar.gz cpython-20ae4c60258479a0732d12af292f422679444e2c.tar.bz2 |
bpo-24596: Decref module in PyRun_SimpleFileExFlags() on SystemExit (GH-7918) (GH-8070)
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.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 24c476b..64b874e 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -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; } |