Commit e8c8482f authored by Stefan Behnel's avatar Stefan Behnel

minor cleanup of merged pull request, add test

parent 78776053
......@@ -986,9 +986,11 @@ cdef memoryview_fromslice({{memviewslice_name}} memviewslice,
result.view.shape = <Py_ssize_t *> result.from_slice.shape
result.view.strides = <Py_ssize_t *> result.from_slice.strides
# only set suboffsets if actually used, otherwise set to NULL to improve compatibility
result.view.suboffsets = NULL
for i in range(ndim):
if result.from_slice.suboffsets[i] >= 0:
for suboffset in result.from_slice.suboffsets[:ndim]:
if suboffset >= 0:
result.view.suboffsets = <Py_ssize_t *> result.from_slice.suboffsets
break
......
......@@ -1012,3 +1012,13 @@ def test_assignment_in_conditional_expression(bint left):
c = a if left else b
for i in range(c.shape[0]):
print c[i]
def test_cpython_offbyone_issue_23349():
"""
>>> print(test_cpython_offbyone_issue_23349())
testing
"""
cdef unsigned char[:] v = bytearray(b"testing")
# the following returns 'estingt' without the workaround
return bytearray(v).decode('ascii')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment