From ca620906e7bce485f3596ed16bc6dc4362dd0ff0 Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Wed, 22 May 2024 19:33:25 +0200 Subject: [PATCH 1/4] Add unit test multiple_registration + currently produces a wonderful 36 errors :D --- unittest/CMakeLists.txt | 3 ++ unittest/multiple_registration.cpp | 28 +++++++++++++++++++ unittest/python/test_multiple_registration.py | 1 + 3 files changed, 32 insertions(+) create mode 100644 unittest/multiple_registration.cpp create mode 100644 unittest/python/test_multiple_registration.py diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt index d0c216fb..72bfb1bb 100644 --- a/unittest/CMakeLists.txt +++ b/unittest/CMakeLists.txt @@ -30,6 +30,7 @@ endmacro(ADD_LIB_UNIT_TEST) add_dependencies(build_tests ${PYWRAP}) add_lib_unit_test(matrix) +add_lib_unit_test(multiple_registration) if(BUILD_TESTING_SCIPY) find_scipy() add_lib_unit_test(sparse_matrix) @@ -101,6 +102,8 @@ endif() add_lib_unit_test(bind_virtual_factory) add_python_lib_unit_test("py-matrix" "unittest/python/test_matrix.py") +add_python_lib_unit_test("py-multiple-registration" + "unittest/python/test_multiple_registration.py") add_python_lib_unit_test("py-tensor" "unittest/python/test_tensor.py") add_python_lib_unit_test("py-geometry" "unittest/python/test_geometry.py") diff --git a/unittest/multiple_registration.cpp b/unittest/multiple_registration.cpp new file mode 100644 index 00000000..32940d4a --- /dev/null +++ b/unittest/multiple_registration.cpp @@ -0,0 +1,28 @@ +#include "eigenpy/registration.hpp" +#include + +namespace bp = boost::python; + +class X { + public: + X() {} + void operator()() { printf("DOOT\n"); } +}; + +class X_wrapper : public X, bp::wrapper { + public: + static void expose() { + if (!eigenpy::register_symbolic_link_to_registered_type()) { + bp::class_("X", bp::init<>()).def("__call__", &X::operator()); + } + } +}; + +BOOST_PYTHON_MODULE(multiple_registration) { + X_wrapper::expose(); + X_wrapper::expose(); + X_wrapper::expose(); + X_wrapper::expose(); + X_wrapper::expose(); + X_wrapper::expose(); +} diff --git a/unittest/python/test_multiple_registration.py b/unittest/python/test_multiple_registration.py new file mode 100644 index 00000000..d414596b --- /dev/null +++ b/unittest/python/test_multiple_registration.py @@ -0,0 +1 @@ +import multiple_registration # noqa From 26b14d5cca3c39c4f40223854ad2a1d59464b797 Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Wed, 22 May 2024 19:37:13 +0200 Subject: [PATCH 2/4] registration.hpp : apply suggested incref() fix --- include/eigenpy/registration.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/eigenpy/registration.hpp b/include/eigenpy/registration.hpp index 7644f291..a2f13fc9 100644 --- a/include/eigenpy/registration.hpp +++ b/include/eigenpy/registration.hpp @@ -45,6 +45,7 @@ inline bool register_symbolic_link_to_registered_type() { const bp::converter::registration* reg = bp::converter::registry::query(info); bp::handle<> class_obj(reg->get_class_object()); + bp::incref(class_obj.get()); bp::scope().attr(reg->get_class_object()->tp_name) = bp::object(class_obj); return true; } @@ -61,6 +62,7 @@ inline bool register_symbolic_link_to_registered_type(const Visitor& visitor) { const bp::converter::registration* reg = bp::converter::registry::query(info); bp::handle<> class_obj(reg->get_class_object()); + bp::incref(class_obj.get()); bp::object object(class_obj); bp::scope().attr(reg->get_class_object()->tp_name) = object; registration_class cl(object); From a2c9cf24ba22f29a01b742bd0361422c2887b11e Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Wed, 22 May 2024 19:40:36 +0200 Subject: [PATCH 3/4] changelog: sync --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d6f540b..b79831e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added - Added a deprecation call policy shortcut ([#466](https://github.com/stack-of-tasks/eigenpy/pull/466)) +### Fixed +- Fix register_symbolic_link_to_registered_type() for multiple successive registrations ([#](https://github.com/stack-of-tasks/eigenpy/pull/471)) + ## [3.5.1] - 2024-04-25 ### Fixed From 7b27e7a62926851b7fc9101fa7cdada4f1803711 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Wed, 22 May 2024 19:41:04 +0200 Subject: [PATCH 4/4] changelog: fix link --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b79831e5..9cdd40e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added a deprecation call policy shortcut ([#466](https://github.com/stack-of-tasks/eigenpy/pull/466)) ### Fixed -- Fix register_symbolic_link_to_registered_type() for multiple successive registrations ([#](https://github.com/stack-of-tasks/eigenpy/pull/471)) +- Fix register_symbolic_link_to_registered_type() for multiple successive registrations ([#471](https://github.com/stack-of-tasks/eigenpy/pull/471)) ## [3.5.1] - 2024-04-25