GH-50831: [Python] Avoid aborting on read-only output buffers - #50833
Open
erichanwang wants to merge 1 commit into
Open
GH-50831: [Python] Avoid aborting on read-only output buffers#50833erichanwang wants to merge 1 commit into
erichanwang wants to merge 1 commit into
Conversation
|
Thanks for opening a pull request! This pull request has been automatically converted to a draft because its title doesn't match Arrow's required format. If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format? or After updating the title, you can mark the pull request as ready for review. See also: |
erichanwang
marked this pull request as ready for review
August 9, 2026 01:07
Reranko05
reviewed
Aug 9, 2026
Reranko05
left a comment
Collaborator
There was a problem hiding this comment.
Can you follow the Arrow PR desc template and edit the PR desc accordingly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
pa.output_stream()currently aborts the Python process when passed a read-only buffer such aspa.py_buffer(b'x')or amemoryview, because the C++ fixed-size buffer writer checksbuffer->is_mutable(). A Python API misuse should raise a Python exception instead of terminating the interpreter.What changes are included in this PR?
python/pyarrow/io.pxi: validate that a buffer passed toFixedSizeBufferWriteris mutable and raise a PythonValueErrorbefore constructing the C++ writer.python/pyarrow/tests/test_io.py: add regression coverage for read-only buffers and preserve successful writes to mutable buffers.Fixes #50831.
Are these changes tested?
Yes. Focused
pyarrowIO regression tests were added for the read-only buffer path and the valid mutable-buffer path. The local Arrow checkout also passesgit diff --check; the available Arrow CI checks are passing.Are there any user-facing changes?
Yes. Passing a read-only buffer to
pa.output_stream()now raises a Python exception instead of aborting the process. Valid mutable-buffer behavior is unchanged.This PR contains a "Critical Fix". This fixes a bug that causes a crash when the API contract is upheld by passing a buffer object that is accepted by the Python API but is read-only.
pa.output_stream()aborts the process on a read-only buffer #50831