This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jaraco
Recipients christian.steinmeyer, jack__d, jaraco, xtreak
Date 2021-07-16.00:26:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626395216.36.0.651483357723.issue44638@roundup.psfhosted.org>
In-reply-to
Content
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
```
History
Date User Action Args
2021-07-16 00:26:56jaracosetrecipients: + jaraco, xtreak, jack__d, christian.steinmeyer
2021-07-16 00:26:56jaracosetmessageid: <1626395216.36.0.651483357723.issue44638@roundup.psfhosted.org>
2021-07-16 00:26:56jaracolinkissue44638 messages
2021-07-16 00:26:56jaracocreate