◐ Shell
clean mode source ↗

Message 266072 - Python tracker

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.