gh-132747: Fix NULL dereference when calling a method's __get__ manually (#132772)

This commit is contained in:
Peter Bierma 2025-04-21 17:09:34 -04:00 committed by GitHub
parent c8e0b6e684
commit fa70bf8593
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 1 deletions

View file

@ -145,7 +145,7 @@ method_get(PyObject *self, PyObject *obj, PyObject *type)
return NULL;
}
if (descr->d_method->ml_flags & METH_METHOD) {
if (PyType_Check(type)) {
if (type == NULL || PyType_Check(type)) {
return PyCMethod_New(descr->d_method, obj, NULL, descr->d_common.d_type);
} else {
PyErr_Format(PyExc_TypeError,