summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-02-28 00:18:43 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2016-02-28 00:18:43 (GMT)
commitef85a1ac1510203a06c15f1483b76f2f20b80ede (patch)
tree8440aa6d04968755fd02e9c421c75f45f70dcf3f /Python/pythonrun.c
parentf9ce84b19531531d2f5748fb51404f5149fbd0fb (diff)
downloadcpython-ef85a1ac1510203a06c15f1483b76f2f20b80ede.zip
cpython-ef85a1ac1510203a06c15f1483b76f2f20b80ede.tar.gz
cpython-ef85a1ac1510203a06c15f1483b76f2f20b80ede.tar.bz2
Issue #22836: Keep exception reports sensible despite errors
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index ece709c..9b5f62d 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1299,8 +1299,11 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
/* only print colon if the str() of the
object is not the empty string
*/
- if (s == NULL)
+ if (s == NULL) {
+ PyErr_Clear();
err = -1;
+ PyFile_WriteString(": <exception str() failed>", f);
+ }
else if (!PyString_Check(s) ||
PyString_GET_SIZE(s) != 0)
err = PyFile_WriteString(": ", f);
@@ -1309,6 +1312,9 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
Py_XDECREF(s);
}
/* try to write a newline in any case */
+ if (err < 0) {
+ PyErr_Clear();
+ }
err += PyFile_WriteString("\n", f);
}
Py_DECREF(value);