summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-02-09 10:43:21 +1000
committerNick Coghlan <ncoghlan@gmail.com>2014-02-09 10:43:21 +1000
commit8fd1a1bb584ddf16b04afd49e2dda4df7eddac54 (patch)
tree2c6ad59ed67437980a6999cea5fd3e434d200dc4 /Python/pythonrun.c
parent2b5a591d53680dd90bdaa58297bd70a681563f5d (diff)
downloadcpython-8fd1a1bb584ddf16b04afd49e2dda4df7eddac54.tar.gz
Close #20500: Don't trigger PyObject_Str assertion at shutdown
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index ff9569bdd2..34a291f353 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1792,6 +1792,11 @@ handle_system_exit(void)
exitcode = (int)PyLong_AsLong(value);
else {
PyObject *sys_stderr = _PySys_GetObjectId(&PyId_stderr);
+ /* We clear the exception here to avoid triggering the assertion
+ * in PyObject_Str that ensures it won't silently lose exception
+ * details.
+ */
+ PyErr_Clear();
if (sys_stderr != NULL && sys_stderr != Py_None) {
PyFile_WriteObject(value, sys_stderr, Py_PRINT_RAW);
} else {