File tree 2 files changed +20
-0
lines changed 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -554,6 +554,22 @@ TEST_SUBMODULE(class_, m) {
554
554
});
555
555
556
556
test_class::pr4220_tripped_over_this::bind_empty0 (m);
557
+
558
+ py::object parent_metaclass = py::reinterpret_borrow<py::object>((PyObject *) &PyType_Type);
559
+ py::dict attributes;
560
+
561
+ attributes[" test" ] = py::cpp_function (
562
+ [](py::object self [[maybe_unused]], py::object x, py::object y) {
563
+ py::print (x, y);
564
+ return 0 ;
565
+ },
566
+ py::arg (" x" ),
567
+ py::kw_only (),
568
+ py::arg (" y" ),
569
+ py::is_method (py::none ())
570
+ );
571
+
572
+ m.attr (" KwOnlyMethod" ) = parent_metaclass (" MwOnlyMethod" , py::make_tuple (), attributes);
557
573
}
558
574
559
575
template <int N>
Original file line number Diff line number Diff line change @@ -501,3 +501,7 @@ def test_pr4220_tripped_over_this():
501
501
m .Empty0 ().get_msg ()
502
502
== "This is really only meant to exercise successful compilation."
503
503
)
504
+
505
+
506
+ def test_kw_only ():
507
+ assert (m .KwOnlyMethod ().test ("x" , y = "y" ) == 0 )
You can’t perform that action at this time.
0 commit comments