Skip to content

Commit 356a68d

Browse files
committed
Issue #21932: Ooops, os.read(fd, size) allocates a buffer of size bytes, even
if the file is much smaller. Add @bigmemtest decorator to the new test_large_read().
1 parent 9bc89f2 commit 356a68d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/test/test_os.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ def test_read(self):
123123
self.assertEqual(type(s), bytes)
124124
self.assertEqual(s, b"spam")
125125

126-
def test_large_read(self):
126+
@support.cpython_only
127+
@support.bigmemtest(size=INT_MAX + 10, memuse=1, dry_run=False)
128+
def test_large_read(self, size):
127129
with open(support.TESTFN, "wb") as fp:
128130
fp.write(b'test')
129131
self.addCleanup(support.unlink, support.TESTFN)
130132

131133
# Issue #21932: Make sure that os.read() does not raise an
132134
# OverflowError for size larger than INT_MAX
133-
size = INT_MAX + 10
134135
with open(support.TESTFN, "rb") as fp:
135136
data = os.read(fp.fileno(), size)
136137

0 commit comments

Comments
 (0)