Skip to content

Conversation

@eric-wieser
Copy link
Member

This previously raisd OSError: [Errno 22] Invalid argument while trying to seek to byte -1 of the file.

It now raises ValueError: cannot mmap an empty file

The simple fix is not to write the file at all if we know it's already long enough.

In future we could consider allowing memmap to do an extra write behind the scenes to ensure the fiel is not empty, but that seems out of scope.

Fixes gh-12653

This previously raisd `OSError: [Errno 22] Invalid argument` while trying to seek to byte -1 of the file.

It now raises `ValueError: cannot mmap an empty file`

The simple fix is not to write the file at all if we know it's already long enough.

In future we could consider allowing memmap to do an extra write behind the scenes to ensure the fiel is not empty, but that seems out of scope.

Fixes numpygh-12653
Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

The new unit test matches the case in the reported issue, and I double checked locally that the full ValueError matches the one from the the standard library mmap, which is hard to argue with. CI is all green with the fix & the patch diff on codecov is 100 % as well. Commit message typos not worth fixing.

Thanks Eric

@tylerjereddy tylerjereddy merged commit c73865c into numpy:master Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

np.memmap throws OSError when size is zero

2 participants