gh-57060: populate Py_buffer strides field for ctypes arrays. - #4714
gh-57060: populate Py_buffer strides field for ctypes arrays.#4714vanossj wants to merge 6 commits into
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
|
@skrah would you be willing to review these changes? Thanks. |
517b4fb to
fe89b9a
Compare
fe89b9a to
c13e305
Compare
MaxwellDupre
left a comment
There was a problem hiding this comment.
Ran ok:
Ran 3 tests in 0.002s
OK
|
This PR is stale because it has been open for 30 days with no activity. |
# Conflicts: # Lib/test/test_ctypes/test_pep3118.py # Modules/_ctypes/_ctypes.c # Modules/_ctypes/_ctypes_test.c # Modules/_ctypes/ctypes.h # Modules/_ctypes/stgdict.c
PyBUF_SIMPLE requests crashed on a multidimensional array: ndim > 1 implies shape != NULL (see PyBuffer_IsContiguous()). The buffer is C contiguous, so it can be exposed as flat. Also, only a multidimensional array is not Fortran contiguous, and BufferError is more appropriate than TypeError. Clear the strides when the shape which they point into is freed.
_testbuffer.ndarray already exposes the raw Py_buffer, and it can also request particular flags, which the buffer_info() helper could not.
|
I have merged the current main into this and made a few changes on top:
Thank you for the patch, and sorry that it took so long. |
bpo-12851: populate Py_buffer strides field for ctypes arrays.
PEP 3118 specifies that if
PyBUF_STIDESis set in the flags argument forPyCData_NewGetBuffer,However it also says that the strides field of Py_buffer:
This patch follows the latter, setting
stridesfor ctypes arrays (ndim>0) but not for other ctypes typeshttps://bugs.python.org/issue12851