[issue32742] zipfile extractall needlessly re-wraps ZipInfo instances

2018-03-27 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

There is an obscure behavior change introduced by this PR. Technically a ZIP 
file can contain several entries with the same name. Currently extractall() 
will extract the last of them multiple times.  The result doesn't differ from 
when extract it only once, there is just a waste of time. After merging this PR 
extractall() will extract different entries to the same location. If one of the 
is a directory, and other is a file, extractall() will fail.

I'm not sure it can be considered a valid ZIP file, but currently the zipfile 
module supports it.

On other hand, what is the benefit of using `self.infolist()` instead of 
`self.namelist()`?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32742] zipfile extractall needlessly re-wraps ZipInfo instances

2018-02-01 Thread Peter Bengtsson

Change by Peter Bengtsson :


--
keywords: +patch
pull_requests: +5298
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32742] zipfile extractall needlessly re-wraps ZipInfo instances

2018-02-01 Thread Peter Bengtsson

Peter Bengtsson  added the comment:

(PS. I'm new to filing Python bugs and submitting patches. I *think* this is 
the right version. I've only been looking at 'master'.)

--
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32742] zipfile extractall needlessly re-wraps ZipInfo instances

2018-02-01 Thread Peter Bengtsson

New submission from Peter Bengtsson :

The ZipFile class as a extractall method [0] that allows you to leave the 
'members' empty. If empty, the 'members' becomes a list of all the *names* of 
files in the zip. Then it iterates over the names as sends each to 
`self._extract_member`. But that method needs it to be a ZipInfo object instead 
of a file name, so it re-wraps it [2].

Instead we can use `self.infolist()` to avoid that re-wrapping inside each 
`self._extract_member` call. 


[0] 
hhttps://github.com/python/cpython/blob/12e7cd8a51956a5ce373aac692ae6366c5f86584/Lib/zipfile.py#L1579
[1] 
https://github.com/python/cpython/blob/12e7cd8a51956a5ce373aac692ae6366c5f86584/Lib/zipfile.py#L1586
[2] 
https://github.com/python/cpython/blob/12e7cd8a51956a5ce373aac692ae6366c5f86584/Lib/zipfile.py#L1615-L1616

--
components: Library (Lib)
messages: 311434
nosy: peterbe
priority: normal
severity: normal
status: open
title: zipfile extractall needlessly re-wraps ZipInfo instances
type: enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com