diff --git a/Objects/typeobject.c b/Objects/typeobject.c index e87763a54d4ae8..813b77a9002bcf 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -7611,7 +7611,7 @@ type_add_method(PyTypeObject *type, PyMethodDef *meth) descr = PyDescr_NewClassMethod(type, meth); } else if (meth->ml_flags & METH_STATIC) { - PyObject *mod = PyObject_GetAttr((PyObject*)type, &_Py_ID(__module__)); + PyObject *mod = type_module(type); PyErr_Clear(); PyObject *cfunc = PyCFunction_NewEx(meth, (PyObject*)type, mod); Py_XDECREF(mod);