From 301256cf1e3a626694a991d9548dab66daafc5e3 Mon Sep 17 00:00:00 2001 From: Jakob van Santen Date: Wed, 18 Sep 2024 11:48:43 +0200 Subject: [PATCH] Avoid setting __doc__ on instance methods --- src/object/function.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/object/function.cpp b/src/object/function.cpp index ec787cf15..7b6ab9f08 100644 --- a/src/object/function.cpp +++ b/src/object/function.cpp @@ -586,6 +586,13 @@ BOOST_PYTHON_DECL void add_to_namespace( BOOST_PYTHON_DECL object const& add_doc(object const& attribute, char const* doc) { +#if PY_VERSION_HEX >= 0x03000000 + if (PyInstanceMethod_Check(attribute.ptr())) { +#else + if (PyMethod_Check(attribute.ptr())) { +#endif + return attribute; + } return function::add_doc(attribute, doc); }