New submission from Christian Steinmeyer <christian.steinmeyer.1...@gmail.com>:
When executing the code below with the attached zip file (or any other that has one or more files directly at root level), I get a "ValueError: seek of closed file". It seems, the zipfile handle being part of the `TestClass` instance is being closed, when the `zipfile.Path` is garbage collected, when it is no longer referenced. Since `zipfile.Path` even takes a `zipfile.Zipfile` as an argument, I don't think it is intended? It surprised me at least. ``` import zipfile class TestClass: def __init__(self, path): self.zip_file = zipfile.ZipFile(path) def iter_dir(self): return [each.name for each in zipfile.Path(self.zip_file).iterdir()] def read(self, filename): with self.zip_file.open(filename) as file: print(file.read()) root = "zipfile.zip" test = TestClass(root) files = test.iter_dir() test.read(files[0]) ``` ---------- components: Library (Lib) files: zipfile.zip messages: 397483 nosy: christian.steinmeyer priority: normal severity: normal status: open title: zipfile.ZipFile is closed when zipfile.Path is closed type: behavior versions: Python 3.8 Added file: https://bugs.python.org/file50150/zipfile.zip _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44638> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com