diff --git a/native/python/pyjp_module.cpp b/native/python/pyjp_module.cpp index 7e9db267f..e2a50b1f3 100644 --- a/native/python/pyjp_module.cpp +++ b/native/python/pyjp_module.cpp @@ -174,26 +174,22 @@ PyObject* PyJP_GetAttrDescriptor(PyTypeObject *type, PyObject *attr_name) for (Py_ssize_t i = 0; i < n; ++i) { PyTypeObject *type2 = (PyTypeObject*) PyTuple_GetItem(mro, i); - if (type2->tp_dict != NULL) { - PyObject *res = PyDict_GetItem(type2->tp_dict, attr_name); - if (res) - { - Py_INCREF(res); - return res; - } - } + PyObject *res = PyDict_GetItem(PyType_GetDict(type2), attr_name); + if (res) + { + Py_INCREF(res); + return res; + } } // Last check is id in the parent { - if (Py_TYPE(type)->tp_dict != NULL) { - PyObject *res = PyDict_GetItem(Py_TYPE(type)->tp_dict, attr_name); - if (res) - { - Py_INCREF(res); - return res; - } - } + PyObject *res = PyDict_GetItem(PyType_GetDict(Py_TYPE(type)), attr_name); + if (res) + { + Py_INCREF(res); + return res; + } } return NULL;