Skip to content
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
1 change: 1 addition & 0 deletions python/pyarrow/io.pxi
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
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.

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.

The testing description now matches the in-process regression.

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