summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-04-26 11:05:47 (GMT)
committerGitHub <noreply@github.com>2019-04-26 11:05:47 (GMT)
commit4cb525a1f0cba152d1da61e531f2ad5db633120a (patch)
tree1f1763445e6150950986d8ba8e24181375124a7a /Modules
parent00db7c73af4f60df61e9df87cde7401c3ed9df69 (diff)
downloadcpython-4cb525a1f0cba152d1da61e531f2ad5db633120a.zip
cpython-4cb525a1f0cba152d1da61e531f2ad5db633120a.tar.gz
cpython-4cb525a1f0cba152d1da61e531f2ad5db633120a.tar.bz2
bpo-36356: pymain_exit_error() only call pymain_free() for exit (GH-12968)
Add _Py_INIT_HAS_EXITCODE() macro.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 6a7f735..68f0b99 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -570,7 +570,12 @@ exit_sigint(void)
static void _Py_NO_RETURN
pymain_exit_error(_PyInitError err)
{
- pymain_free();
+ if (_Py_INIT_HAS_EXITCODE(err)) {
+ /* If it's an error rather than a regular exit, leave Python runtime
+ alive: _Py_ExitInitError() uses the current exception and use
+ sys.stdout in this case. */
+ pymain_free();
+ }
_Py_ExitInitError(err);
}