[Lldb-commits] [lldb] [lldb] Check for abstract methods implementation in Scripted Plugin Objects (PR #71260)
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Fri Nov 3 18:08:51 PDT 2023
================
@@ -103,24 +139,79 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
"Resulting object is not initialized.");
std::apply(
- [&method, &expected_return_object](auto &&...args) {
+ [&init, &expected_return_object](auto &&...args) {
llvm::consumeError(expected_return_object.takeError());
- expected_return_object = method(args...);
+ expected_return_object = init(args...);
},
transformed_args);
- if (llvm::Error e = expected_return_object.takeError())
- return std::move(e);
- result = std::move(expected_return_object.get());
+ if (!expected_return_object)
+ return expected_return_object.takeError();
+ result = expected_return_object.get();
}
- if (!result.IsValid())
+ if (!result.IsValid() || !result.HasAttribute("__class__"))
+ return llvm::createStringError(
+ llvm::inconvertibleErrorCode(),
+ "Resulting object is not a valid Python Object.");
+
+ PythonObject obj_class = result.GetAttributeValue("__class__");
+
+ PythonString obj_class_name =
+ obj_class.GetAttributeValue("__name__").AsType<PythonString>();
+
+ PythonObject object_class_mapping_proxy =
+ obj_class.GetAttributeValue("__dict__");
+
+ PythonCallable dict_converter = PythonModule::BuiltinsModule()
+ .ResolveName("dict")
+ .AsType<PythonCallable>();
+ if (!dict_converter.IsAllocated())
+ return llvm::createStringError(
+ llvm::inconvertibleErrorCode(),
+ "Resulting object is not a valid Python Object.");
----------------
bulbazord wrote:
This may be true but I think we should change the error message because:
1. For the sake of debugging LLDB, a different error message makes it more clear which code path was taken.
2. I think we could give a better error message, hopefully? I'm not sure what would lead to this error condition in the first place....
WDYT?
https://github.com/llvm/llvm-project/pull/71260
More information about the lldb-commits
mailing list