Skip to content

Demonstrate that the conduit feature does not help with C++-to-Python conversions #5544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
'"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
Loading