Author rhansen
Recipients rhansen
Date 2015-01-30.01:33:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1422581625.15.0.953074491863.issue23352@psf.upfronthosting.co.za>
In-reply-to
Content
According to https://docs.python.org/2/c-api/buffer.html#the-new-style-py-buffer-struct if the suboffsets member of Py_buffer is non-NULL and all members of the array are negative, the buffer may be contiguous.

PyBuffer_IsContiguous() does not behave this way.  It assumes that if the suboffsets member is non-NULL then at least one member of the array is non-negative, and thus assumes that the buffer is non-contiguous.  This is not always correct.

One consequence of this bug is PyBuffer_ToContiguous() (and thus memoryview.tobytes()) falls back to slow (and currently buggy, see issue #23349) memory copying code.

Attached is a patch that fixes this bug.  The patch is against 2.7 but can be trivially modified to apply to 3.x.
History
Date User Action Args
2015-01-30 01:33:45rhansensetrecipients: + rhansen
2015-01-30 01:33:45rhansensetmessageid: <1422581625.15.0.953074491863.issue23352@psf.upfronthosting.co.za>
2015-01-30 01:33:44rhansenlinkissue23352 messages
2015-01-30 01:33:43rhansencreate