diff --git a/src/Dispatcher.cxx b/src/Dispatcher.cxx index db38857..c2153eb 100644 --- a/src/Dispatcher.cxx +++ b/src/Dispatcher.cxx @@ -484,7 +484,12 @@ bool CPyCppyy::InsertDispatcher(CPPScope* klass, PyObject* bases, PyObject* dct, // Python class to keep the inheritance tree intact) for (const auto& name : protected_names) { PyObject* disp_dct = PyObject_GetAttr(disp_proxy, PyStrings::gDict); +#if PY_VERSION_HEX < 0x30d00f0 PyObject* pyf = PyMapping_GetItemString(disp_dct, (char*)name.c_str()); +#else + PyObject* pyf = nullptr; + PyMapping_GetOptionalItemString(disp_dct, (char*)name.c_str(), &pyf); +#endif if (pyf) { PyObject_SetAttrString((PyObject*)klass, (char*)name.c_str(), pyf); Py_DECREF(pyf);