Skip to content

Commit

Permalink
conduit test failure
Browse files Browse the repository at this point in the history
Returning a class instance from an external module fails with TypeError
  • Loading branch information
rhaschke committed Feb 23, 2025
1 parent d8565ac commit ffca482
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/exo_planet_pybind11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ namespace test_cpp_conduit {
PYBIND11_MODULE(exo_planet_pybind11, m) {
wrap_traveler(m);
m.def("wrap_very_lonely_traveler", [m]() { wrap_very_lonely_traveler(m); });

py::class_<A>(m, "A", "class A").def(py::init<>()).def_readwrite("value", &A::value);
}

} // namespace test_cpp_conduit
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cpp_conduit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ TEST_SUBMODULE(cpp_conduit, m) {

wrap_traveler(m);
wrap_lonely_traveler(m);

py::class_<B>(m, "B", "class B").def(py::init<>()).def_readonly("a", &B::a);
}

} // namespace test_cpp_conduit
Expand Down
9 changes: 9 additions & 0 deletions tests/test_cpp_conduit.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,12 @@ def test_exo_planet_pybind11_wrap_very_lonely_traveler():
'"pybind11_tests::test_cpp_conduit::LonelyTraveler"$',
):
exo_planet_pybind11.wrap_very_lonely_traveler()


def test_return_instance_from_exo_planet():
b = home_planet.B()
a = b.a

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 3.11 β€’ ubuntu-latest β€’ x64

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON -DCMAKE_CXX_FLAGS="-D_=1"

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 3.13 β€’ ubuntu-20.04 β€’ x64

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 3.12 β€’ ubuntu-20.04 β€’ x64

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 3.9 β€’ ubuntu-20.04 β€’ x64

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.11 β€’ ubuntu-20.04 β€’ x64

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.10 β€’ ubuntu-20.04 β€’ x64

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 graalpy-24.1 β€’ ubuntu-20.04 β€’ x64

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.9 β€’ ubuntu-20.04 β€’ x64

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A

Check failure on line 171 in tests/test_cpp_conduit.py

View workflow job for this annotation

GitHub Actions / 🐍 pypy-3.8 β€’ ubuntu-20.04 β€’ x64 -DPYBIND11_FINDPYTHON=ON

test_return_instance_from_exo_planet TypeError: Unable to convert function return value to a Python type! The signature was (self: pybind11_tests.cpp_conduit.B) -> pybind11_tests::test_cpp_conduit::A
assert a.value == 0.0

a.value = 1.0
assert a.value == 1.0
8 changes: 8 additions & 0 deletions tests/test_cpp_conduit_traveler_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ struct PremiumTraveler : Traveler {
struct LonelyTraveler {};
struct VeryLonelyTraveler : LonelyTraveler {};

struct A {
double value;
};

struct B {
A a{0.0};
};

} // namespace test_cpp_conduit
} // namespace pybind11_tests

0 comments on commit ffca482

Please sign in to comment.