Skip to content

[3.15] gh-158102: Add tests for the slice C API (GH-158120) - #158291

Merged
serhiy-storchaka merged 1 commit into
python:3.15from
serhiy-storchaka:backport-8c056c3-3.15
Oct 9, 2026
Merged

serhiy-storchaka merged 1 commit into
python:3.15from
serhiy-storchaka:backport-8c056c3-3.15

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Test PySlice_Check(), PySlice_New(), PySlice_GetIndices(), PySlice_Unpack(), PySlice_AdjustIndices() and PySlice_GetIndicesEx().

PySlice_GetIndicesEx() is tested both as a macro and as a deprecated function, including the case when __index__() resizes the sequence whose size is passed as the length: the macro evaluates it after PySlice_Unpack(), the function before the call.

(cherry picked from commit 8c056c3)

The conflicts were only in the registration lists, which have diverged from main: Modules/Setup.stdlib.in and Modules/_testlimitedcapi.c. The registration calls here are in PyInit__testlimitedcapi(), which returns PyObject *, so the new check returns NULL instead of -1.

Modules/_testlimitedcapi/slice.c is identical to main: Include/pyabi.h in 3.15 accepts Py_TARGET_ABI3T set to 0x030f0000.

Test PySlice_Check(), PySlice_New(), PySlice_GetIndices(), PySlice_Unpack(),
PySlice_AdjustIndices() and PySlice_GetIndicesEx() -- both the macro and the
deprecated function.

Document the length and step precondition of PySlice_AdjustIndices()
(cherry picked from commit 8c056c3)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
@serhiy-storchaka
serhiy-storchaka merged commit 29abf59 into python:3.15 Oct 9, 2026
58 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the backport-8c056c3-3.15 branch October 9, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant