(self, size)
| 346 | "needs INT_MAX < PY_SSIZE_T_MAX") |
| 347 | @support.bigmemtest(size=INT_MAX + 10, memuse=1, dry_run=False) |
| 348 | def test_large_readinto(self, size): |
| 349 | self.addCleanup(os_helper.unlink, os_helper.TESTFN) |
| 350 | create_file(os_helper.TESTFN, b'test') |
| 351 | |
| 352 | # Issue #21932: For readinto the buffer contains the length rather than |
| 353 | # a length being passed explicitly to read, should still get capped to a |
| 354 | # valid size / not raise an OverflowError for sizes larger than INT_MAX. |
| 355 | buffer = bytearray(INT_MAX + 10) |
| 356 | with open(os_helper.TESTFN, "rb") as fp: |
| 357 | length = os.readinto(fp.fileno(), buffer) |
| 358 | |
| 359 | # The test does not try to read more than 2 GiB at once because the |
| 360 | # operating system is free to return less bytes than requested. |
| 361 | self.assertEqual(length, 4) |
| 362 | self.assertEqual(buffer[:4], b'test') |
| 363 | |
| 364 | def test_write(self): |
| 365 | # os.write() accepts bytes- and buffer-like objects but not strings |
nothing calls this directly
no test coverage detected