Skip to content

Fix OverflowError in _get_slice on 32-bit platforms (#145)#147

Merged
Ezibenroc merged 3 commits intomasterfrom
fix_145
Apr 22, 2026
Merged

Fix OverflowError in _get_slice on 32-bit platforms (#145)#147
Ezibenroc merged 3 commits intomasterfrom
fix_145

Conversation

@Ezibenroc
Copy link
Copy Markdown
Owner

@Ezibenroc Ezibenroc commented Apr 21, 2026

On 32-bit platforms, len(range(first_elt, last_elt+sign, step)) overflows Py_ssize_t when the bitmap spans values near 2**31-1 (e.g. BitMap([0, 2**31-1])). Replace with abs(last_elt - first_elt) + 1, which is pure Python int arithmetic and cannot overflow. Apply the same fix to AbstractBitMap64._get_slice, where the same overflow would occur on any platform for bitmaps spanning [0, 2**63-1].

Also restore pytest test.py in the wheel build CI (dropped in fd5bd43).

On 32-bit platforms, len(range(first_elt, last_elt+sign, step)) overflows
Py_ssize_t when the bitmap spans values near 2**31-1 (e.g. BitMap([0, 2**31-1])).
Replace with abs(last_elt - first_elt) + 1, which is pure Python int arithmetic
and cannot overflow. Apply the same fix to AbstractBitMap64._get_slice, where the
same overflow would occur on any platform for bitmaps spanning [0, 2**63-1].

Also restore pytest test.py in the wheel build CI (dropped in fd5bd43).
@Ezibenroc Ezibenroc merged commit a77da03 into master Apr 22, 2026
43 checks passed
@Ezibenroc Ezibenroc deleted the fix_145 branch April 24, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant