| 5728 | reason="PyPy's memoryview currently does not track exports. See: " |
| 5729 | "https://foss.heptapod.net/pypy/pypy/-/issues/3724") |
| 5730 | def test_mmap_close(self): |
| 5731 | # The old buffer protocol was not safe for some things that the new |
| 5732 | # one is. But `frombuffer` always used the old one for a long time. |
| 5733 | # Checks that it is safe with the new one (using memoryviews) |
| 5734 | with tempfile.TemporaryFile(mode='wb') as tmp: |
| 5735 | tmp.write(b"asdf") |
| 5736 | tmp.flush() |
| 5737 | mm = mmap.mmap(tmp.fileno(), 0) |
| 5738 | arr = np.frombuffer(mm, dtype=np.uint8) |
| 5739 | with pytest.raises(BufferError): |
| 5740 | mm.close() # cannot close while array uses the buffer |
| 5741 | del arr |
| 5742 | mm.close() |
| 5743 | |
| 5744 | class TestFlat: |
| 5745 | def setup_method(self): |