diff options
author | Guido van Rossum <guido@python.org> | 1996-12-05 21:52:32 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-12-05 21:52:32 (GMT) |
commit | cbd1e4eb5f7ce78300387ae872d89153c2b4dd66 (patch) | |
tree | 7a79bee6ba4f7f949c26242002d573d132c4e9a1 /Objects | |
parent | 3c5936afc5f067b3b591f554c31e1cfdce460fad (diff) | |
download | cpython-cbd1e4eb5f7ce78300387ae872d89153c2b4dd66.zip cpython-cbd1e4eb5f7ce78300387ae872d89153c2b4dd66.tar.gz cpython-cbd1e4eb5f7ce78300387ae872d89153c2b4dd66.tar.bz2 |
Yet more elaborate message for exception in __del__.
Make gcc -Wall happy.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/classobject.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index 551bdce..0ae6a61 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -353,10 +353,10 @@ newinstanceobject(class, arg, kw) init = instance_getattr1(inst, initstr); if (init == NULL) { err_clear(); - if (arg != NULL && (!is_tupleobject(arg) || - gettuplesize(arg) != 0) - || kw != NULL && (!is_dictobject(kw) || - getdictsize(kw) != 0)) { + if ((arg != NULL && (!is_tupleobject(arg) || + gettuplesize(arg) != 0)) + || (kw != NULL && (!is_dictobject(kw) || + getdictsize(kw) != 0))) { err_setstr(TypeError, "this constructor takes no arguments"); DECREF(inst); @@ -411,19 +411,32 @@ instance_dealloc(inst) delstr = newstringobject("__del__"); if ((del = instance_getattr1(inst, delstr)) != NULL) { object *res = call_object(del, (object *)NULL); - DECREF(del); if (res == NULL) { - PyObject *f = sysget("stderr"); + object *f, *t, *v, *tb; + err_fetch(&t, &v, &tb); + f = sysget("stderr"); err_clear(); if (f != NULL) { - writestring("exception in ", f); - writestring(PyString_AsString( - inst->in_class->cl_name), f); - writestring(".__del__() ignored\n", f); + writestring("Exception ", f); + if (t) { + writeobject(t, f, Py_PRINT_RAW); + if (v && v != None) { + writestring(": ", f); + writeobject(v, f, 0); + } + } + writestring(" in ", f); + writeobject(del, f, 0); + writestring(" ignored\n", f); + err_clear(); /* Just in case */ } + Py_XDECREF(t); + Py_XDECREF(v); + Py_XDECREF(tb); } else DECREF(res); + DECREF(del); } /* Restore the saved exception and undo the temporary revival */ err_restore(error_type, error_value, error_traceback); @@ -632,7 +645,6 @@ instance_compare(inst, other) long outcome; result = instance_compare1(inst, other); if (result == NULL || !is_intobject(result)) { - error: err_clear(); return (inst < other) ? -1 : 1; } |