summaryrefslogtreecommitdiff
path: root/Python/errors.c
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-02-28 03:16:11 +0000
committerMartin Panter <vadmium+py@gmail.com>2016-02-28 03:16:11 +0000
commit4ae421a65024184263b1e070b4c9fe9e32168097 (patch)
tree543d5e553567a92922a3c6f7278c22c01fefe3e0 /Python/errors.c
parent817f63254d10fbbe2f94f4e9fead6e9adc3d0161 (diff)
downloadcpython-4ae421a65024184263b1e070b4c9fe9e32168097.tar.gz
Issue #22836: Keep exception reports sensible despite errors
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 5ff1e4c81a..47d7c4b992 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -900,8 +900,12 @@ PyErr_WriteUnraisable(PyObject *obj)
if (obj) {
if (PyFile_WriteString("Exception ignored in: ", f) < 0)
goto done;
- if (PyFile_WriteObject(obj, f, 0) < 0)
- goto done;
+ if (PyFile_WriteObject(obj, f, 0) < 0) {
+ PyErr_Clear();
+ if (PyFile_WriteString("<object repr() failed>", f) < 0) {
+ goto done;
+ }
+ }
if (PyFile_WriteString("\n", f) < 0)
goto done;
}
@@ -946,8 +950,12 @@ PyErr_WriteUnraisable(PyObject *obj)
if (v && v != Py_None) {
if (PyFile_WriteString(": ", f) < 0)
goto done;
- if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
- goto done;
+ if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0) {
+ PyErr_Clear();
+ if (PyFile_WriteString("<exception str() failed>", f) < 0) {
+ goto done;
+ }
+ }
}
if (PyFile_WriteString("\n", f) < 0)
goto done;