From 78071836f8c1108e5ac5ba312d041dc7e6341bcb Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Sun, 11 Jun 2023 11:10:11 -0700 Subject: [PATCH 1/2] bugfix: fixes a test suite bug in the __new__ example --- tests/test_class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_class.cpp b/tests/test_class.cpp index ca925917e6..10bf41b3e1 100644 --- a/tests/test_class.cpp +++ b/tests/test_class.cpp @@ -85,7 +85,7 @@ TEST_SUBMODULE(class_, m) { .def_static("new_instance", &NoConstructor::new_instance, "Return an instance"); py::class_(m, "NoConstructorNew") - .def(py::init([](const NoConstructorNew &self) { return self; })) // Need a NOOP __init__ + .def(py::init<>()) // Need a NOOP __init__ .def_static("__new__", [](const py::object &) { return NoConstructorNew::new_instance(); }); From 3a9c0efe9658e6d3deb0f000338f597e11527f38 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 12 Jul 2023 09:08:03 -0700 Subject: [PATCH 2/2] See https://github.com/pybind/pybind11/pull/4698#discussion_r1227107682 --- tests/test_class.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_class.cpp b/tests/test_class.cpp index 10bf41b3e1..7241bc8818 100644 --- a/tests/test_class.cpp +++ b/tests/test_class.cpp @@ -85,7 +85,7 @@ TEST_SUBMODULE(class_, m) { .def_static("new_instance", &NoConstructor::new_instance, "Return an instance"); py::class_(m, "NoConstructorNew") - .def(py::init<>()) // Need a NOOP __init__ + .def(py::init([]() { return nullptr; })) // Need a NOOP __init__ .def_static("__new__", [](const py::object &) { return NoConstructorNew::new_instance(); });