mirror of https://github.com/python/cpython
Fix core dump in repr() of instancemethod whose class==NULL.
This commit is contained in:
parent
84a79a8d25
commit
4066769b91
|
@ -2058,15 +2058,19 @@ instancemethod_repr(PyMethodObject *a)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sfuncname = PyString_AS_STRING(funcname);
|
sfuncname = PyString_AS_STRING(funcname);
|
||||||
klassname = PyObject_GetAttrString(klass, "__name__");
|
if (klass == NULL)
|
||||||
if (klassname == NULL)
|
|
||||||
PyErr_Clear();
|
|
||||||
else if (!PyString_Check(klassname)) {
|
|
||||||
Py_DECREF(klassname);
|
|
||||||
klassname = 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)
|
if (self == NULL)
|
||||||
sprintf(buffer, "<unbound method %.100s.%.100s>",
|
sprintf(buffer, "<unbound method %.100s.%.100s>",
|
||||||
sklassname, sfuncname);
|
sklassname, sfuncname);
|
||||||
|
|
Loading…
Reference in New Issue