summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Python')
-rw-r--r--Python/errors.c10
-rw-r--r--Python/pythonrun.c8
2 files changed, 15 insertions, 3 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 5cbf5c9..e7c221c 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -696,12 +696,18 @@ PyErr_WriteUnraisable(PyObject *obj)
PyFile_WriteString(className, f);
if (v && v != Py_None) {
PyFile_WriteString(": ", f);
- PyFile_WriteObject(v, f, 0);
+ if (PyFile_WriteObject(v, f, 0) < 0) {
+ PyErr_Clear();
+ PyFile_WriteString("<exception repr() failed>", f);
+ }
}
Py_XDECREF(moduleName);
}
PyFile_WriteString(" in ", f);
- PyFile_WriteObject(obj, f, 0);
+ if (PyFile_WriteObject(obj, f, 0) < 0) {
+ PyErr_Clear();
+ PyFile_WriteString("<object repr() failed>", f);
+ }
PyFile_WriteString(" ignored\n", f);
PyErr_Clear(); /* Just in case */
}
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);