File tree 2 files changed +17
-10
lines changed
2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -387,6 +387,20 @@ PYBIND11_WARNING_POP
387
387
#define PYBIND11_CONCAT (first, second ) first##second
388
388
#define PYBIND11_ENSURE_INTERNALS_READY pybind11::detail::get_internals ();
389
389
390
+ #if !defined(GRAALVM_PYTHON)
391
+ # define PYBIND11_PYCFUNCTION_GET_DOC (func ) ((func)->m_ml->ml_doc)
392
+ # define PYBIND11_PYCFUNCTION_SET_DOC (func, doc ) \
393
+ do { \
394
+ (func)->m_ml ->ml_doc = (doc); \
395
+ } while (0 )
396
+ #else
397
+ # define PYBIND11_PYCFUNCTION_GET_DOC (func ) (GraalPyCFunction_GetDoc((PyObject *) (func)))
398
+ # define PYBIND11_PYCFUNCTION_SET_DOC (func, doc ) \
399
+ do { \
400
+ GraalPyCFunction_SetDoc ((PyObject *) (func), (doc)); \
401
+ } while (0 )
402
+ #endif
403
+
390
404
#define PYBIND11_CHECK_PYTHON_VERSION \
391
405
{ \
392
406
const char *compiled_ver \
Original file line number Diff line number Diff line change @@ -633,18 +633,11 @@ class cpp_function : public function {
633
633
}
634
634
}
635
635
636
- /* Install docstring */
637
636
auto *func = (PyCFunctionObject *) m_ptr;
638
- #if !defined(GRAALVM_PYTHON)
639
- std::free (const_cast <char *>(func->m_ml ->ml_doc ));
640
637
// 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 ());
643
- #else
644
- std::free (const_cast <char *>(GraalPyCFunction_GetDoc (m_ptr)));
645
- GraalPyCFunction_SetDoc (
646
- m_ptr, signatures.empty () ? nullptr : PYBIND11_COMPAT_STRDUP (signatures.c_str ()));
647
- #endif
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);
648
641
649
642
if (rec->is_method ) {
650
643
m_ptr = PYBIND11_INSTANCE_METHOD_NEW (m_ptr, rec->scope .ptr ());
You can’t perform that action at this time.
0 commit comments