[Python-checkins] r53974 - in python/branches/release25-maint: Misc/NEWS Python/errors.c

neal.norwitz python-checkins at python.org
Tue Feb 27 00:46:56 CET 2007


Author: neal.norwitz
Date: Tue Feb 27 00:46:51 2007
New Revision: 53974

Modified:
   python/branches/release25-maint/Misc/NEWS
   python/branches/release25-maint/Python/errors.c
Log:
Fix SF bug #1669182.  Handle string exceptions even if unraisable (ie in __del__).

Modified: python/branches/release25-maint/Misc/NEWS
==============================================================================
--- python/branches/release25-maint/Misc/NEWS	(original)
+++ python/branches/release25-maint/Misc/NEWS	Tue Feb 27 00:46:51 2007
@@ -12,6 +12,9 @@
 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.

Modified: python/branches/release25-maint/Python/errors.c
==============================================================================
--- python/branches/release25-maint/Python/errors.c	(original)
+++ python/branches/release25-maint/Python/errors.c	Tue Feb 27 00:46:51 2007
@@ -590,7 +590,11 @@
 		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, '.');


More information about the Python-checkins mailing list