[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-16 Thread miss-islington
miss-islington added the comment: New changeset 29358e93f2bb60983271c14ce4c2f3eab35a60ca by Jason R. Coombs in branch 'main': bpo-44638: Add a reference to the zipp project and hint as to how to use it. (GH-27188) https://github.com/python/cpython/commit/29358e93f2bb60983271c14ce4c2f3eab35a6

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-16 Thread Jason R. Coombs
Change by Jason R. Coombs : -- pull_requests: +25724 pull_request: https://github.com/python/cpython/pull/27188 ___ Python tracker ___ _

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-16 Thread Christian Steinmeyer
Christian Steinmeyer added the comment: Thank you for the in depth look Jason! Especially that last comment was very useful to me. Perhaps it would make sense to add something like this to the documentation of zipfile. I'm not sure what would be the best hint, but perhaps in zipfile.Path's do

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-15 Thread Jason R. Coombs
Jason R. Coombs added the comment: > My python version is 3.8.9 and zipp is at 3.5.0 (but 3.4.1 behaves the same > for me). It's not enough to have `zipp` 3.5.0. You need to use `zipp.Path` over `zipfile.Path`. -- ___ Python tracker

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-15 Thread Jason R. Coombs
Change by Jason R. Coombs : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> Using zipfile.Path with several files prematurely closes zip ___ Python tracker

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-15 Thread Jason R. Coombs
Jason R. Coombs added the comment: Changing the repro to: ``` import zipfile try: import zipp except ImportError: import zipfile as zipp zip_file = zipfile.ZipFile('zipfile.zip') name = zip_file.namelist()[0] zipp.Path(zip_file) zip_file.open(name) ``` I'm able now to test against z

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-15 Thread Jason R. Coombs
Jason R. Coombs added the comment: Even simpler: ``` zip_file = zipfile.ZipFile('zipfile.zip') name = zip_file.namelist()[0] zipfile.Path(zip_file) zip_file.open(name) ``` -- ___ Python tracker

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-15 Thread Jason R. Coombs
Jason R. Coombs added the comment: This also reproduces the failure: ``` zip_file = zipfile.ZipFile('zipfile.zip') path = zipfile.Path(zip_file) name = zip_file.namelist()[0] del path zip_file.open(name) ``` Removing `del path` bypasses the issue. Something about the destructor for zipfile.P

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-15 Thread Jason R. Coombs
Jason R. Coombs added the comment: Even simpler: ``` import zipfile zip_file = zipfile.ZipFile('zipfile.zip') names = [each.name for each in zipfile.Path(zip_file).iterdir()] zip_file.open(names[0]) ``` -- ___ Python tracker

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-15 Thread Jason R. Coombs
Jason R. Coombs added the comment: Here's a much simpler repro that avoids the class construction but triggers the same error: ``` import zipfile zip_file = zipfile.ZipFile('zipfile.zip') names = [each.name for each in zipfile.Path(zip_file).iterdir()] with zip_file.open(names[0]) as file:

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-15 Thread Jason R. Coombs
Jason R. Coombs 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

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-15 Thread Christian Steinmeyer
Christian Steinmeyer 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) # t

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-14 Thread Jack DeVries
Jack DeVries added the comment: I'm not able to reproduce this on my machine; the script runs without any issue. > the `TestClass` instance is being closed What do you mean by this statement? You aren't doing anything to TestClass or its instance ("test") in this script. They remain in scope

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-14 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: This seems similar to https://bugs.python.org/issue40564 -- nosy: +jaraco, xtreak ___ Python tracker ___ __

[issue44638] zipfile.ZipFile is closed when zipfile.Path is closed

2021-07-14 Thread Christian Steinmeyer
New submission from Christian Steinmeyer : 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,