diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h index cdda66abc562b..5f5665c495770 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h @@ -74,7 +74,8 @@ class ScriptedPythonInterface : virtual public ScriptedInterface { if (!class_dict.HasKey(method_name)) SET_CASE_AND_CONTINUE(method_name, AbstractMethodCheckerCases::eNotImplemented) - auto callable_or_err = class_dict.GetItem(method_name); + llvm::Expected callable_or_err = + class_dict.GetItem(method_name); if (!callable_or_err) { llvm::consumeError(callable_or_err.takeError()); SET_CASE_AND_CONTINUE(method_name, diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp index a2a287a6714db..d2f795cb5a20a 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp @@ -810,6 +810,17 @@ bool PythonCallable::Check(PyObject *py_obj) { if (!py_obj) return false; + PythonObject python_obj(PyRefType::Borrowed, py_obj); + + // Handle staticmethod/classmethod descriptors by extracting the + // `__func__` attribute. + if (python_obj.HasAttribute("__func__")) { + PythonObject function_obj = python_obj.GetAttributeValue("__func__"); + if (!function_obj.IsAllocated()) + return false; + return PyCallable_Check(function_obj.release()); + } + return PyCallable_Check(py_obj); }