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.

classification
Title: module zipfile issue on closing
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Using zipfile.Path with several files prematurely closes zip
View: 40564
Assigned To: Nosy List: bastian.ebeling, jaraco, xtreak
Priority: normal Keywords:

Created on 2020-08-26 07:31 by bastian.ebeling, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg375917 - (view) Author: Bastian Ebeling (bastian.ebeling) Date: 2020-08-26 07:31
When trying to open an archive and read internal binary streams, for me it occurs, that the file-stream gets closed.
As a code-Snippet:

import zipfile
srcfile=zipfile.ZipFile('file.zip')
a=zipfile.Path(srcfile,"data1.bin").read_bytes()
b=zipfile.Path(srcfile,"data2.bin").read_bytes()

the second call results in the ValueError: seek of closed file

A quick and dirty solution (as an idea) is to change close() for the _SharedFile to run self.close() instead of self._close(findeobj) in the end (somehow around line 772).

Hopefully that helps
msg375918 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-08-26 08:03
This seems to be a duplicate of issue40564 . Can you please add the python version you are using?
msg375922 - (view) Author: Bastian Ebeling (bastian.ebeling) Date: 2020-08-26 08:47
My used python Version is
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)] on win32
Indead - this issue seems to be the same as 40564, but maybe my suggested solution is helpful?
msg376061 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-08-29 12:59
Thanks, I am closing this in favor of issue40564. Jason has provided some possible approaches in issue40564 (msg375964) and would be helpful to follow the discussion there since it has more details.
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85806
2020-08-29 12:59:33xtreaksetstatus: open -> closed

superseder: Using zipfile.Path with several files prematurely closes zip

nosy: + jaraco
messages: + msg376061
resolution: duplicate
stage: resolved
2020-08-26 08:47:56bastian.ebelingsetmessages: + msg375922
components: + Library (Lib)
2020-08-26 08:03:12xtreaksetnosy: + xtreak
messages: + msg375918
2020-08-26 07:31:32bastian.ebelingcreate