Jason R. Coombs <jar...@jaraco.com> added the comment:
I was able to replicate the error using the script as posted: ``` draft $ cat > issue44638.py 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]) draft $ python -m zipfile -c zipfile.zip issue44638.py draft $ python issue44638.py Traceback (most recent call last): File "/Users/jaraco/draft/issue44638.py", line 18, in <module> test.read(files[0]) File "/Users/jaraco/draft/issue44638.py", line 12, in read with self.zip_file.open(filename) as file: File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/zipfile.py", line 1518, in open fheader = zef_file.read(sizeFileHeader) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/zipfile.py", line 741, in read self._file.seek(self._pos) ValueError: seek of closed file ``` ---------- _______________________________________ 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