(self)
| 1005 | self.access = access |
| 1006 | |
| 1007 | def __enter__(self): |
| 1008 | self.f = open(TESTFN, "w+b") |
| 1009 | self.f.write(random.randbytes(100)) |
| 1010 | self.f.flush() |
| 1011 | |
| 1012 | m = mmap.mmap(self.f.fileno(), 100, access=self.access) |
| 1013 | |
| 1014 | class X: |
| 1015 | def __index__(self): |
| 1016 | m.close() |
| 1017 | return 10 |
| 1018 | |
| 1019 | return (m, X) |
| 1020 | |
| 1021 | def __exit__(self, exc_type, exc_value, traceback): |
| 1022 | self.f.close() |