Since Python 3.12, in the implementation of 'classobject.h' the function PyMethod_GET_SELF performs an assert to check that the passed function argument is a method:
It's fair that the assert fails, because the Python type of meth in this context is not a PyMethod_Type, but the
CustomInstanceMethod_Type from cppyy. However, as can be seen in the implementation of CustomInstanceMethod_New, the actual C++ type that implements this custom cppy type is just the regular PyMethodObject.
Hence, this commit suggests new assert-free CustomInstanceMethod_GET_* macros that replace the PyMethod_GET_* macros in the context of the CustomInstanceMethod implementation.
Since Python 3.12, in the implementation of 'classobject.h' the function PyMethod_GET_SELF performs an assert to check that the passed function argument is a method:
It's fair that the assert fails, because the Python type of
meth
in this context is not aPyMethod_Type
, but theCustomInstanceMethod_Type
from cppyy. However, as can be seen in the implementation ofCustomInstanceMethod_New
, the actual C++ type that implements this custom cppy type is just the regularPyMethodObject
.Hence, this commit suggests new assert-free
CustomInstanceMethod_GET_*
macros that replace thePyMethod_GET_*
macros in the context of theCustomInstanceMethod
implementation.