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
test_mmap does not handle ValueError when no large file support #71114
Comments
test_mmap fails on an android emulator running an x86 system image at API level 21. ====================================================================== Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_mmap.py", line 755, in test_large_filesize
with self._make_test_file(0x17FFFFFFF, b" ") as f:
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_mmap.py", line 738, in _make_test_file
f.seek(num_zeroes)
ValueError: cannot fit 'int' into an offset-sized integer ====================================================================== Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_mmap.py", line 750, in test_large_offset
with self._make_test_file(0x14FFFFFFF, b" ") as f:
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_mmap.py", line 738, in _make_test_file
f.seek(num_zeroes)
ValueError: cannot fit 'int' into an offset-sized integer Ran 35 tests in 0.134s FAILED (errors=2, skipped=6) |
This is other manifestation of bpo-26926. |
f.seek(number) raises ValueError (ValueError: cannot fit 'int' into an offset-sized integer) when 'number' is greater than the size allowed by off_t. ValueError is not handled in test_mmap to detect that large file is not supported. With this patch, test_large_filesize and test_large_offset are skipped as expected on an Android emulator. |
I'm wondering in what cases other exceptions (OSError, OverflowError) can be raised? Initial test was added in bpo-4681. |
On linux with large file support, OSError is raised when the file system limit is exceeded, here with ext4: >>> f.seek(2**44 - 2**11)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument
>>> f.seek(2**44 - 2**12)
17592186040320
>>> f.write(b'A' * 2**11)
2048
>>> f.write(b'A' * 2**11)
2048
>>> f.tell()
17592186044416
>>> f.write(b'A' * 2**11)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 27] File too large On the Android emulator (no large file support): >>> f.seek(2**31)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: cannot fit 'int' into an offset-sized integer
>>> f.seek(2**31 - 1)
2147483647
>>> f.write(b'A')
1
>>> f.tell()
-2147483648
>>> f.flush()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 75] Value too large for defined data type Surprisingly f.write(b'A') does not raise an exception. |
When OverflowError is raised? Shouldn't it be replaced with ValueError? |
New changeset bca81ea8f898 by Serhiy Storchaka in branch '3.5': New changeset 6147a2c99db0 by Serhiy Storchaka in branch 'default': |
At least Python implementation of io.FileIO can raise OverflowError (from os.lseek()). Thus OverflowError should be kept. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: