diff options
author | Guido van Rossum <guido@python.org> | 2001-08-17 13:59:27 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-17 13:59:27 (GMT) |
commit | 4066769b91797f2442df67a097231e3ca6e2139b (patch) | |
tree | 51a0baaea37aa50251f57933e800ff064576297e /Objects/classobject.c | |
parent | 84a79a8d25279645b6b6b536e1f8748723ef1209 (diff) | |
download | cpython-4066769b91797f2442df67a097231e3ca6e2139b.zip cpython-4066769b91797f2442df67a097231e3ca6e2139b.tar.gz cpython-4066769b91797f2442df67a097231e3ca6e2139b.tar.bz2 |
Fix core dump in repr() of instancemethod whose class==NULL.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r-- | Objects/classobject.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index 9652dfe..0f39d4b 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -2058,15 +2058,19 @@ instancemethod_repr(PyMethodObject *a) } else sfuncname = PyString_AS_STRING(funcname); - klassname = PyObject_GetAttrString(klass, "__name__"); - if (klassname == NULL) - PyErr_Clear(); - else if (!PyString_Check(klassname)) { - Py_DECREF(klassname); + if (klass == NULL) klassname = NULL; + else { + klassname = PyObject_GetAttrString(klass, "__name__"); + if (klassname == NULL) + PyErr_Clear(); + else if (!PyString_Check(klassname)) { + Py_DECREF(klassname); + klassname = NULL; + } + else + sklassname = PyString_AS_STRING(klassname); } - else - sklassname = PyString_AS_STRING(klassname); if (self == NULL) sprintf(buffer, "<unbound method %.100s.%.100s>", sklassname, sfuncname); |