We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
py::stride used to have size_t to store start/stop/step values. Nowadays it uses ssize_t (issue #776, PR #782).
py::stride
size_t
ssize_t
The issues is that py::slice::compute still accepts size_t* arguments instead of ssize_t*
py::slice::compute
size_t*
ssize_t*
pybind11/include/pybind11/pytypes.h
Lines 1073 to 1079 in 086d53e
C-style pointers casts must be read here as reinterpret_cast<>.
reinterpret_cast<>
To obtain signed strides user should have something like
ssize_t start, stop, step, slicelength; if (!slice.compute( N, reinterpret_cast<size_t*>(&start), reinterpret_cast<size_t*>(&stop), reinterpret_cast<size_t*>(&step), reinterpret_cast<size_t*>(&slicelength) )){ throw py::error_already_set(); } ... // use extracted values
So reinterpret_cast<> appears twice: in user code and in the library (in py::slice::compute) converting back and forth ssize_t* and size_t*.
The non-breaking solution would be to add an overload for ssize_t* to py::slice.
py::slice
bool compute(ssize_t length, ssize_t *start, ssize_t *stop, ssize_t *step, ssize_t *slicelength) const { return PySlice_GetIndicesEx((PYBIND11_SLICE_OBJECT *) m_ptr, length, start, stop, step, slicelength) == 0; }
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
py::stride
used to havesize_t
to store start/stop/step values. Nowadays it usesssize_t
(issue #776, PR #782).The issues is that
py::slice::compute
still acceptssize_t*
arguments instead ofssize_t*
pybind11/include/pybind11/pytypes.h
Lines 1073 to 1079 in 086d53e
C-style pointers casts must be read here as
reinterpret_cast<>
.To obtain signed strides user should have something like
So
reinterpret_cast<>
appears twice: in user code and in the library (inpy::slice::compute
) converting back and forthssize_t*
andsize_t*
.The non-breaking solution would be to add an overload for
ssize_t*
topy::slice
.The text was updated successfully, but these errors were encountered: