mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705)
On macOS, fix reading from and writing into a file with a size larger than 2 GiB.
This commit is contained in:
parent
0f11a88622
commit
74a8b6ea7e
5 changed files with 33 additions and 26 deletions
|
@ -5,12 +5,12 @@ import os
|
|||
import stat
|
||||
import sys
|
||||
import unittest
|
||||
from test.support import TESTFN, requires, unlink
|
||||
from test.support import TESTFN, requires, unlink, bigmemtest
|
||||
import io # C implementation of io
|
||||
import _pyio as pyio # Python implementation of io
|
||||
|
||||
# size of file to create (>2 GiB; 2 GiB == 2,147,483,648 bytes)
|
||||
size = 2500000000
|
||||
size = 2_500_000_000
|
||||
|
||||
class LargeFileTest:
|
||||
"""Test that each file function works as expected for large
|
||||
|
@ -45,6 +45,15 @@ class LargeFileTest:
|
|||
raise cls.failureException('File was not truncated by opening '
|
||||
'with mode "wb"')
|
||||
|
||||
# _pyio.FileIO.readall() uses a temporary bytearray then casted to bytes,
|
||||
# so memuse=2 is needed
|
||||
@bigmemtest(size=size, memuse=2, dry_run=False)
|
||||
def test_large_read(self, _size):
|
||||
# bpo-24658: Test that a read greater than 2GB does not fail.
|
||||
with self.open(TESTFN, "rb") as f:
|
||||
self.assertEqual(len(f.read()), size + 1)
|
||||
self.assertEqual(f.tell(), size + 1)
|
||||
|
||||
def test_osstat(self):
|
||||
self.assertEqual(os.stat(TESTFN)[stat.ST_SIZE], size+1)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue