(self)
| 610 | Misbehaved(bad_size).read() |
| 611 | |
| 612 | def test_RawIOBase_read_gh60107(self): |
| 613 | # gh-60107: Ensure a "Raw I/O" which keeps a reference to the |
| 614 | # mutable memory doesn't allow making a mutable bytes. |
| 615 | class RawIOKeepsReference(self.MockRawIOWithoutRead): |
| 616 | def __init__(self, *args, **kwargs): |
| 617 | self.buf = None |
| 618 | super().__init__(*args, **kwargs) |
| 619 | |
| 620 | def readinto(self, buf): |
| 621 | # buf is the bytearray so keeping a reference to it doesn't keep |
| 622 | # the memory alive; a memoryview does. |
| 623 | self.buf = memoryview(buf) |
| 624 | buf[0:4] = self._read_stack.pop() |
| 625 | return 3 |
| 626 | |
| 627 | with self.assertRaises(BufferError): |
| 628 | rawio = RawIOKeepsReference([b"1234"]) |
| 629 | rawio.read(4) |
| 630 | |
| 631 | def test_types_have_dict(self): |
| 632 | test = ( |
nothing calls this directly
no test coverage detected