Skip to content

gh-160688: Add tests for PyObject_CopyData() and PyBuffer_FillContiguousStrides() - #160701

Open
Davien21 wants to merge 3 commits into
python:mainfrom
Davien21:capi-tests-buffer-copy
Open

Davien21 wants to merge 3 commits into
python:mainfrom
Davien21:capi-tests-buffer-copy

Conversation

@Davien21

@Davien21 Davien21 commented Oct 26, 2026 •

Copy link
Copy Markdown

Adds _testlimitedcapi wrappers and tests for PyObject_CopyData() and PyBuffer_FillContiguousStrides(), which had none. Same layout as gh-158102: a new Modules/_testlimitedcapi/buffer.c and Lib/test/test_capi/test_buffer.py.

The PyObject_CopyData() tests cover C and Fortran contiguous 2-D copies in all four combinations, non-contiguous sources and destinations, multi-byte items, and the error paths. They don't cover copies between buffers of different shapes, because that path gives wrong results today; I'll open a separate issue for it.

Tested with a --with-pydebug build: ./python -m test -j4 test_capi test_buffer passes. Breaking the strided copy loop and the Fortran branch of PyBuffer_FillContiguousStrides() in Objects/abstract.c makes all three new tests fail.

@python-cla-bot

python-cla-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Oct 26, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@Davien21

Davien21 commented Nov 1, 2026

Copy link
Copy Markdown
Author

Opened gh-161081 for the different-shapes case mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant