summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-02-26 23:46:51 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-02-26 23:46:51 (GMT)
commit036b3beca80cf2ccd6ffe98cf5d10eb8ee5e8b19 (patch)
tree184711d659bb2ee0659e80f580b3d3949337c596
parent366bf0d9cb0847c70290cf6200a99a27969ec5ee (diff)
downloadcpython-036b3beca80cf2ccd6ffe98cf5d10eb8ee5e8b19.zip
cpython-036b3beca80cf2ccd6ffe98cf5d10eb8ee5e8b19.tar.gz
cpython-036b3beca80cf2ccd6ffe98cf5d10eb8ee5e8b19.tar.bz2
Fix SF bug #1669182. Handle string exceptions even if unraisable (ie in __del__).
-rw-r--r--Misc/NEWS3
-rw-r--r--Python/errors.c6
2 files changed, 8 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 9a46c42..8b0e7e2 100644
--- 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.
diff --git a/Python/errors.c b/Python/errors.c
index f31f025..bc77c3c 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -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, '.');