diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/classobject.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c index 506faab..68505f1 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -2208,6 +2208,12 @@ instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw) } if (self == Py_None) self = NULL; + if (self == NULL && classObj == NULL) { + PyErr_SetString(PyExc_TypeError, + "unbound methods must have non-NULL im_class"); + return NULL; + } + return PyMethod_New(func, self, classObj); } |