Christian Steinmeyer <christian.steinmeyer.1...@gmail.com> added the comment:

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

----------

_______________________________________
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

Reply via email to