@@ -573,8 +573,7 @@ class cpp_function : public function {
573573 // chain.
574574 chain_start = rec;
575575 rec->next = chain;
576- auto rec_capsule
577- = reinterpret_borrow<capsule>(((PyCFunctionObject *) m_ptr)->m_self );
576+ auto rec_capsule = reinterpret_borrow<capsule>(PyCFunction_GET_SELF (m_ptr));
578577 rec_capsule.set_pointer (unique_rec.release ());
579578 guarded_strdup.release ();
580579 } else {
@@ -634,12 +633,11 @@ class cpp_function : public function {
634633 }
635634 }
636635
637- /* Install docstring */
638636 auto *func = (PyCFunctionObject *) m_ptr;
639- std::free (const_cast <char *>(func->m_ml ->ml_doc ));
640637 // Install docstring if it's non-empty (when at least one option is enabled)
641- func->m_ml ->ml_doc
642- = signatures.empty () ? nullptr : PYBIND11_COMPAT_STRDUP (signatures.c_str ());
638+ auto *doc = signatures.empty () ? nullptr : PYBIND11_COMPAT_STRDUP (signatures.c_str ());
639+ std::free (const_cast <char *>(PYBIND11_PYCFUNCTION_GET_DOC (func)));
640+ PYBIND11_PYCFUNCTION_SET_DOC (func, doc);
643641
644642 if (rec->is_method ) {
645643 m_ptr = PYBIND11_INSTANCE_METHOD_NEW (m_ptr, rec->scope .ptr ());
@@ -2780,8 +2778,8 @@ get_type_override(const void *this_ptr, const type_info *this_type, const char *
27802778 }
27812779
27822780 /* Don't call dispatch code if invoked from overridden function.
2783- Unfortunately this doesn't work on PyPy. */
2784- #if !defined(PYPY_VERSION)
2781+ Unfortunately this doesn't work on PyPy and GraalPy . */
2782+ #if !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
27852783# if PY_VERSION_HEX >= 0x03090000
27862784 PyFrameObject *frame = PyThreadState_GetFrame (PyThreadState_Get ());
27872785 if (frame != nullptr ) {
0 commit comments