[New-bugs-announce] [issue23349] memoryview.to_bytes() and PyBuffer_ToContiguous() off-by-one error for non-contiguous buffers

Richard Hansen report at bugs.python.org
Fri Jan 30 02:07:08 CET 2015


New submission from Richard Hansen:

PyBuffer_ToContiguous() has an off-by-one error when copying a buffer it thinks is non-contiguous.

To reproduce, put the following in foo.pyx and compile with Cython v0.21.2:

    cpdef foo():
        cdef unsigned char[:] v = bytearray("testing")
        print repr(memoryview(v).tobytes())

>>> import foo
>>> foo.foo()
'estingt'

(This issue was fixed for Python 3.x in issue #12834 but it was not fixed for Python 2.7.)

----------
components: Interpreter Core
files: PyBuffer_ToContiguous.patch
keywords: patch
messages: 235011
nosy: rhansen
priority: normal
severity: normal
status: open
title: memoryview.to_bytes() and PyBuffer_ToContiguous() off-by-one error for non-contiguous buffers
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file37912/PyBuffer_ToContiguous.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23349>
_______________________________________


More information about the New-bugs-announce mailing list