diff options
author | Miodrag Milanović <mmicko@gmail.com> | 2021-01-02 11:16:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-02 11:16:49 +0100 |
commit | 9b9628047c01a970cfe20f83f2b7129ed109440d (patch) | |
tree | 1db418e9a889dc6fbe6199c5259aac9bd8cbb32f /3rdparty/pybind11/tests/test_sequences_and_iterators.cpp | |
parent | c6cdf30501dcb2da01361229dd66a05dad73a132 (diff) | |
parent | 61b07bc9a664d6a88b85aae99f9756d7569688a9 (diff) | |
download | nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.tar.gz nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.tar.bz2 nextpnr-9b9628047c01a970cfe20f83f2b7129ed109440d.zip |
Merge pull request #549 from YosysHQ/update
Update pybind11 version and fix for future python versions
Diffstat (limited to '3rdparty/pybind11/tests/test_sequences_and_iterators.cpp')
-rw-r--r-- | 3rdparty/pybind11/tests/test_sequences_and_iterators.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/3rdparty/pybind11/tests/test_sequences_and_iterators.cpp b/3rdparty/pybind11/tests/test_sequences_and_iterators.cpp index 87ccf99d..d318052a 100644 --- a/3rdparty/pybind11/tests/test_sequences_and_iterators.cpp +++ b/3rdparty/pybind11/tests/test_sequences_and_iterators.cpp @@ -13,6 +13,8 @@ #include <pybind11/operators.h> #include <pybind11/stl.h> +#include <algorithm> + template<typename T> class NonZeroIterator { const T* ptr_; @@ -81,7 +83,7 @@ TEST_SUBMODULE(sequences_and_iterators, m) { py::class_<Sliceable>(m,"Sliceable") .def(py::init<int>()) .def("__getitem__",[](const Sliceable &s, py::slice slice) { - ssize_t start, stop, step, slicelength; + py::ssize_t start, stop, step, slicelength; if (!slice.compute(s.size, &start, &stop, &step, &slicelength)) throw py::error_already_set(); int istart = static_cast<int>(start); @@ -198,7 +200,7 @@ TEST_SUBMODULE(sequences_and_iterators, m) { size_t start, stop, step, slicelength; if (!slice.compute(s.size(), &start, &stop, &step, &slicelength)) throw py::error_already_set(); - Sequence *seq = new Sequence(slicelength); + auto *seq = new Sequence(slicelength); for (size_t i = 0; i < slicelength; ++i) { (*seq)[i] = s[start]; start += step; } @@ -319,6 +321,9 @@ TEST_SUBMODULE(sequences_and_iterators, m) { return l; }); + // test_sequence_length: check that Python sequences can be converted to py::sequence. + m.def("sequence_length", [](py::sequence seq) { return seq.size(); }); + // Make sure that py::iterator works with std algorithms m.def("count_none", [](py::object o) { return std::count_if(o.begin(), o.end(), [](py::handle h) { return h.is_none(); }); |