diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 40629f6c24a..a2ecde5b7e5 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -91,9 +91,9 @@ wrapper_repr(PyWrapperDescrObject *descr) static int descr_check(PyDescrObject *descr, PyObject *obj, PyTypeObject *type, - PyObject **pres) + PyObject **pres) { - if (obj == NULL || obj == Py_None) { + if (obj == NULL || (obj == Py_None && type != Py_None->ob_type)) { Py_INCREF(descr); *pres = (PyObject *)descr; return 1; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 8103205f766..30e693ab91a 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1862,8 +1862,6 @@ wrap_descr_get(PyObject *self, PyObject *args, void *wrapped) if (!PyArg_ParseTuple(args, "O|O", &obj, &type)) return NULL; - if (type == NULL) - type = (PyObject *)obj->ob_type; return (*func)(self, obj, type); }