Skip to content

Commit b756519

Browse files
committed
Fix weird return_value_policy::reference in test_stl_binders, and enable those tests
1 parent 73b4a74 commit b756519

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ jobs:
228228
tests/test_[abcdefhijklmnopqrtuwxyz]*.py
229229
tests/test_sequences_and_iterators.py
230230
tests/test_stl.py
231+
tests/test_stl_binders.py
231232
232233
233234
# # Testing on clang using the excellent silkeh clang docker images

tests/test_stl_binders.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ TEST_SUBMODULE(stl_binders, m) {
8686

8787
// test_noncopyable_containers
8888
py::bind_vector<std::vector<E_nc>>(m, "VectorENC");
89-
m.def("get_vnc", &one_to_n<std::vector<E_nc>>, py::return_value_policy::reference);
89+
m.def("get_vnc", &one_to_n<std::vector<E_nc>>);
9090
py::bind_vector<std::deque<E_nc>>(m, "DequeENC");
91-
m.def("get_dnc", &one_to_n<std::deque<E_nc>>, py::return_value_policy::reference);
91+
m.def("get_dnc", &one_to_n<std::deque<E_nc>>);
9292
py::bind_map<std::map<int, E_nc>>(m, "MapENC");
93-
m.def("get_mnc", &times_ten<std::map<int, E_nc>>, py::return_value_policy::reference);
93+
m.def("get_mnc", &times_ten<std::map<int, E_nc>>);
9494
py::bind_map<std::unordered_map<int, E_nc>>(m, "UmapENC");
95-
m.def("get_umnc", &times_ten<std::unordered_map<int, E_nc>>, py::return_value_policy::reference);
95+
m.def("get_umnc", &times_ten<std::unordered_map<int, E_nc>>);
9696
// Issue #1885: binding nested std::map<X, Container<E>> with E non-copyable
9797
py::bind_map<std::map<int, std::vector<E_nc>>>(m, "MapVecENC");
9898
m.def("get_nvnc", [](int n)
@@ -102,11 +102,11 @@ TEST_SUBMODULE(stl_binders, m) {
102102
for (int j = 1; j <= n; j++)
103103
(*m)[i].emplace_back(j);
104104
return m;
105-
}, py::return_value_policy::reference);
105+
});
106106
py::bind_map<std::map<int, std::map<int, E_nc>>>(m, "MapMapENC");
107-
m.def("get_nmnc", &times_hundred<std::map<int, std::map<int, E_nc>>>, py::return_value_policy::reference);
107+
m.def("get_nmnc", &times_hundred<std::map<int, std::map<int, E_nc>>>);
108108
py::bind_map<std::unordered_map<int, std::unordered_map<int, E_nc>>>(m, "UmapUmapENC");
109-
m.def("get_numnc", &times_hundred<std::unordered_map<int, std::unordered_map<int, E_nc>>>, py::return_value_policy::reference);
109+
m.def("get_numnc", &times_hundred<std::unordered_map<int, std::unordered_map<int, E_nc>>>);
110110

111111
// test_vector_buffer
112112
py::bind_vector<std::vector<unsigned char>>(m, "VectorUChar", py::buffer_protocol());

0 commit comments

Comments
 (0)