Commit 4066769b authored by Guido van Rossum's avatar Guido van Rossum

Fix core dump in repr() of instancemethod whose class==NULL.

parent 84a79a8d
...@@ -2058,6 +2058,9 @@ instancemethod_repr(PyMethodObject *a) ...@@ -2058,6 +2058,9 @@ instancemethod_repr(PyMethodObject *a)
} }
else else
sfuncname = PyString_AS_STRING(funcname); sfuncname = PyString_AS_STRING(funcname);
if (klass == NULL)
klassname = NULL;
else {
klassname = PyObject_GetAttrString(klass, "__name__"); klassname = PyObject_GetAttrString(klass, "__name__");
if (klassname == NULL) if (klassname == NULL)
PyErr_Clear(); PyErr_Clear();
...@@ -2067,6 +2070,7 @@ instancemethod_repr(PyMethodObject *a) ...@@ -2067,6 +2070,7 @@ instancemethod_repr(PyMethodObject *a)
} }
else else
sklassname = PyString_AS_STRING(klassname); 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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment