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 christian.steinmeyer
Recipients christian.steinmeyer, jack__d, jaraco, xtreak
Date 2021-07-15.07:11:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626333089.19.0.702509166897.issue44638@roundup.psfhosted.org>
In-reply-to
Content
I work on macOS 11.4 (20F71) (Kernel Version: Darwin 20.5.0).
My python version is 3.8.9 and zipp is at 3.5.0 (but 3.4.1 behaves the same for me).
For me, this is behavior is reproducible.

Let me try to clarify what I mean. 

test = TestClass(root)  # this creates a zipfile handle  (an instance of zipfile.ZipFile) at test.zip_file

files = test.iter_dir()  # this creates multiple instances of zipfile.Path() as part of the list comprehension and these are deferenced afterwards. I found that test.zip_file.fp is closed after this line executes, which to me suggests that the closing of the zipfile.Path also closes the zipfile.ZipFile that was used to create the zipfile.Path.

test.read(files[0])  # this should in theory try to read from the test.zip_file for the first time, but fails because it is closed as per the above.

Here is the full stack trace:
Traceback (most recent call last):
  File "test.py", line 20, in <module>
    test.read(files[0])
  File "test.py", line 12, in read
    with self.zip_file.open(filename) as file:
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/zipfile.py", line 1530, in open
    fheader = zef_file.read(sizeFileHeader)
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/zipfile.py", line 763, in read
    self._file.seek(self._pos)
ValueError: seek of closed file
History
Date User Action Args
2021-07-15 07:11:29christian.steinmeyersetrecipients: + christian.steinmeyer, jaraco, xtreak, jack__d
2021-07-15 07:11:29christian.steinmeyersetmessageid: <1626333089.19.0.702509166897.issue44638@roundup.psfhosted.org>
2021-07-15 07:11:29christian.steinmeyerlinkissue44638 messages
2021-07-15 07:11:28christian.steinmeyercreate