[Mlir-commits] [mlir] 8b73479 - [mlir] Annotate methods on a correct class in PybindAdaptors.h

Alex Zinenko llvmlistbot at llvm.org
Mon Feb 21 04:04:25 PST 2022


Author: Alex Zinenko
Date: 2022-02-21T13:04:19+01:00
New Revision: 8b734798a55bdd8e49d1c0f782382a3c87529352

URL: https://github.com/llvm/llvm-project/commit/8b734798a55bdd8e49d1c0f782382a3c87529352
DIFF: https://github.com/llvm/llvm-project/commit/8b734798a55bdd8e49d1c0f782382a3c87529352.diff

LOG: [mlir] Annotate methods on a correct class in PybindAdaptors.h

The `.def` and `.def_property_readonly` functions in PybindAdaptors.h should
construct the functions as method of the current class rather than as method of
pybind11:none(), which is an object and not even a class.

Depends On D117658

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D117659

Added: 
    

Modified: 
    mlir/include/mlir/Bindings/Python/PybindAdaptors.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Bindings/Python/PybindAdaptors.h b/mlir/include/mlir/Bindings/Python/PybindAdaptors.h
index 9d5a512a4dbe6..661ed48f9c1dd 100644
--- a/mlir/include/mlir/Bindings/Python/PybindAdaptors.h
+++ b/mlir/include/mlir/Bindings/Python/PybindAdaptors.h
@@ -249,7 +249,7 @@ class pure_subclass {
   template <typename Func, typename... Extra>
   pure_subclass &def(const char *name, Func &&f, const Extra &... extra) {
     py::cpp_function cf(
-        std::forward<Func>(f), py::name(name), py::is_method(py::none()),
+        std::forward<Func>(f), py::name(name), py::is_method(thisClass),
         py::sibling(py::getattr(thisClass, name, py::none())), extra...);
     thisClass.attr(cf.name()) = cf;
     return *this;
@@ -259,7 +259,7 @@ class pure_subclass {
   pure_subclass &def_property_readonly(const char *name, Func &&f,
                                        const Extra &... extra) {
     py::cpp_function cf(
-        std::forward<Func>(f), py::name(name), py::is_method(py::none()),
+        std::forward<Func>(f), py::name(name), py::is_method(thisClass),
         py::sibling(py::getattr(thisClass, name, py::none())), extra...);
     auto builtinProperty =
         py::reinterpret_borrow<py::object>((PyObject *)&PyProperty_Type);


        


More information about the Mlir-commits mailing list