diff options
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r-- | Objects/classobject.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index afd4ec3dc6..f9568527b3 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -218,7 +218,7 @@ method_repr(PyMethodObject *a) { PyObject *self = a->im_self; PyObject *func = a->im_func; - PyObject *klass = (PyObject*)Py_TYPE(self); + PyObject *klass; PyObject *funcname = NULL ,*klassname = NULL, *result = NULL; char *defname = "?"; @@ -226,6 +226,7 @@ method_repr(PyMethodObject *a) PyErr_BadInternalCall(); return NULL; } + klass = (PyObject*)Py_TYPE(self); funcname = PyObject_GetAttrString(func, "__name__"); if (funcname == NULL) { @@ -243,8 +244,10 @@ method_repr(PyMethodObject *a) else { klassname = PyObject_GetAttrString(klass, "__name__"); if (klassname == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) { + Py_XDECREF(funcname); return NULL; + } PyErr_Clear(); } else if (!PyUnicode_Check(klassname)) { @@ -263,10 +266,10 @@ method_repr(PyMethodObject *a) return result; } -static long +static Py_hash_t method_hash(PyMethodObject *a) { - long x, y; + Py_hash_t x, y; if (a->im_self == NULL) x = PyObject_Hash(Py_None); else |