]> granicus.if.org Git - python/commitdiff
Fix SF bug #1669182. Handle string exceptions even if unraisable (ie in __del__).
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 26 Feb 2007 23:46:51 +0000 (23:46 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 26 Feb 2007 23:46:51 +0000 (23:46 +0000)
Misc/NEWS
Python/errors.c

index 9a46c4255d3609c33daca1666c816a27e2c10fdd..8b0e7e21dba9d6a101a64b69ce43ae5a07a97414 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 2.5.1c1?
 Core and builtins
 -----------------
 
+- Bug #1669182: prevent crash when trying to print an unraisable error
+  from a string exception.
+
 - Bug #1653736: Properly discard third argument to slot_nb_inplace_power.
 
 - SF #151204:  enumerate() now raises an Overflow error at sys.maxint items.
index f31f025112e72e58996ce6bdff8692106d0156cb..bc77c3c1b701b507c22a498a34d5dd68c053c0ca 100644 (file)
@@ -590,7 +590,11 @@ PyErr_WriteUnraisable(PyObject *obj)
                PyFile_WriteString("Exception ", f);
                if (t) {
                        PyObject* moduleName;
-                       char* className = PyExceptionClass_Name(t);
+                       char* className = NULL;
+                       if (PyExceptionClass_Check(t))
+                               className = PyExceptionClass_Name(t);
+                       else if (PyString_Check(t))
+                               className = PyString_AS_STRING(t);
 
                        if (className != NULL) {
                                char *dot = strrchr(className, '.');