[Lldb-commits] [lldb] [lldb] Check for abstract methods implementation in Scripted Plugin Objects (PR #71260)

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Sat Nov 4 20:00:46 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.");
----------------
medismailben wrote:

I was planning on updating the error message before making the PR but I forgot 😅 Thanks for catching that!

https://github.com/llvm/llvm-project/pull/71260


More information about the lldb-commits mailing list