Skip to content

Commit

Permalink
apacheGH-40153: [Python] Fix OverflowError in foreign_buffer on 32-bi…
Browse files Browse the repository at this point in the history
…t platforms (apache#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 apache#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: apache#40153

Authored-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Antoine Pitrou <antoine@python.org>
  • Loading branch information
mgorny authored and zanmato1984 committed Feb 28, 2024
1 parent d37eca6 commit 609fe31
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/pyarrow/io.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ def foreign_buffer(address, size, base=None):
Object that owns the referenced memory.
"""
cdef:
intptr_t c_addr = address
uintptr_t c_addr = address
int64_t c_size = size
shared_ptr[CBuffer] buf

Expand Down

0 comments on commit 609fe31

Please sign in to comment.