From 379aae7090725b331ab7c60968829087214b33be Mon Sep 17 00:00:00 2001 From: AlexanderMueller Date: Tue, 20 Aug 2024 17:09:24 +0200 Subject: [PATCH] test fix --- include/pybind11/functional.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/pybind11/functional.h b/include/pybind11/functional.h index 8a8c32c0ec..950abb3603 100644 --- a/include/pybind11/functional.h +++ b/include/pybind11/functional.h @@ -14,6 +14,7 @@ #include "pybind11.h" #include +#include PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) PYBIND11_NAMESPACE_BEGIN(detail) @@ -138,17 +139,27 @@ struct type_caster> { }; size_t argCount = 0; + std::cout << "BEFORE codeAttr is not null" << std::endl; handle codeAttr = PyObject_GetAttrString(src.ptr(), "__code__"); + std::cout << "AFTER codeAttr is not null" << std::endl; if (codeAttr) { + std::cout << "codeAttr is not null" << std::endl; argCount = argCountFromFuncCode(codeAttr); } else { + std::cout << "BEFORE callAttr is not null" << std::endl; handle callAttr = PyObject_GetAttrString(src.ptr(), "__call__"); + std::cout << "AFTER callAttr is not null" << std::endl; if (callAttr) { + std::cout << "BEFORE codeAttr2 is not null" << std::endl; handle codeAttr2 = PyObject_GetAttrString(callAttr.ptr(), "__code__"); + std::cout << "AFTER codeAttr2 is not null" << std::endl; argCount = argCountFromFuncCode(codeAttr2) - 1; // we have to remove the self argument } else { // No __code__ or __call__ attribute, this is not a proper Python function + std::cout << "No __code__ or __call__ attribute, this is not a proper Python " + "function" + << std::endl; return false; } }