Skip to content

Navigation Menu

Sign in
Sign up

GH-51229: [Python] Raise instead of crashing on unopened resize #51246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1fanwang wants to merge 2 commits into apache:main
base: main
Choose a base branch
Loading
from 1fanwang:1fannnw/gh-51229-memory-mapped-file-resize
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some comments aren't visible on the classic Files Changed page.

1 change: 1 addition & 0 deletions python/pyarrow/io.pxi
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@ cdef class MemoryMappedFile(NativeFile):
----------
new_size : new size in bytes
"""
self._assert_open()
check_status(self.handle.get().Resize(new_size))

def fileno(self):
Expand Down
5 changes: 5 additions & 0 deletions python/pyarrow/tests/test_io.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,11 @@ def test_memory_map_resize(tmpdir):
assert f.read() == bytes(arr[:SIZE])


def test_memory_map_resize_uninitialized():
Comment thread
1fanwang marked this conversation as resolved.
with pytest.raises(ValueError, match="I/O operation on closed file"):
pa.MemoryMappedFile().resize(0)


Comment on lines +1219 to +1223

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping it in-process per #51246 (comment); with the fix it raises rather than crashing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the PR description needs an update.

def test_memory_zero_length(tmpdir):
path = os.path.join(str(tmpdir), guid())
f = open(path, 'wb')
Expand Down

AltStyle によって変換されたページ (->オリジナル) /