| 6613 | assert_array_equal(np.frombuffer(b''), np.array([])) |
| 6614 | |
| 6615 | def test_mmap_close(self): |
| 6616 | # The old buffer protocol was not safe for some things that the new |
| 6617 | # one is. But `frombuffer` always used the old one for a long time. |
| 6618 | # Checks that it is safe with the new one (using memoryviews) |
| 6619 | with tempfile.TemporaryFile(mode='wb') as tmp: |
| 6620 | tmp.write(b"asdf") |
| 6621 | tmp.flush() |
| 6622 | mm = mmap.mmap(tmp.fileno(), 0) |
| 6623 | arr = np.frombuffer(mm, dtype=np.uint8) |
| 6624 | with pytest.raises(BufferError): |
| 6625 | mm.close() # cannot close while array uses the buffer |
| 6626 | del arr |
| 6627 | mm.close() |
| 6628 | |
| 6629 | class TestFlat: |
| 6630 | def _create_arrays(self): |