diff --git a/src/uproot/source/fsspec.py b/src/uproot/source/fsspec.py index cbbcab0c8..a094cb9bf 100644 --- a/src/uproot/source/fsspec.py +++ b/src/uproot/source/fsspec.py @@ -92,6 +92,9 @@ def chunk(self, start: int, stop: int) -> uproot.source.chunk.Chunk: Request a byte range of data from the file as a :doc:`uproot.source.chunk.Chunk`. """ + if self.closed: + raise OSError(f"memmap is closed for file {self._file_path}") + self._num_requests += 1 self._num_requested_chunks += 1 self._num_requested_bytes += stop - start @@ -129,6 +132,9 @@ def chunks( it is triggered by already-filled chunks, rather than waiting for chunks to be filled. """ + if self.closed: + raise OSError(f"memmap is closed for file {self._file_path}") + self._num_requests += 1 self._num_requested_chunks += len(ranges) self._num_requested_bytes += sum(stop - start for start, stop in ranges)