| 46 | |
| 47 | |
| 48 | class _buffer_reader(_open_buffer): |
| 49 | def __init__(self, buffer): |
| 50 | super().__init__(buffer) |
| 51 | self.initial_tell = self.buffer.tell() |
| 52 | |
| 53 | def __exit__(self, *args): |
| 54 | # `args[0]` is type of exception. When the `read` is abnormal, the file pointer returns to the initial position. |
| 55 | if args[0] is not None: |
| 56 | self.buffer.seek(self.initial_tell) |
| 57 | |
| 58 | |
| 59 | class _buffer_writer(_open_buffer): |