Skip to content

Commit 29d2b16

Browse files
authored
GH-40153: [Python] Fix OverflowError in foreign_buffer on 32-bit platforms (#40158)
Use `uintptr_t` rather than `intptr_t` to fix `OverflowError`, visible e.g. when running `tests/interchange/test_conversion.py` tests on 32-bit platforms. ### Rationale for this change This fixes the `OverflowError`s from #40153, and makes `pyarrow/tests/interchange/` all pass on 32-bit x86. ### What changes are included in this PR? - change the type used to store pointer from `intptr_t` to `uintptr_t` to provide coverage for pointers above `0x80000000`. ### Are these changes tested? These changes are covered by the tests in `pyarrow/tests/interchange`. ### Are there any user-facing changes? It fixes `OverflowError` that can be triggered by working with pandas data types, possibly more (though I'm not sure if this qualifies as a "crash"). * Closes: #40153 Authored-by: Michał Górny <mgorny@gentoo.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent 0988933 commit 29d2b16

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python/pyarrow/io.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,7 @@ def foreign_buffer(address, size, base=None):
19871987
Object that owns the referenced memory.
19881988
"""
19891989
cdef:
1990-
intptr_t c_addr = address
1990+
uintptr_t c_addr = address
19911991
int64_t c_size = size
19921992
shared_ptr[CBuffer] buf
19931993

0 commit comments

Comments
 (0)