[issue32742] zipfile extractall needlessly re-wraps ZipInfo instances

Peter Bengtsson report at bugs.python.org
Thu Feb 1 10:10:53 EST 2018


New submission from Peter Bengtsson <mail at peterbe.com>:

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 <report at bugs.python.org>
<https://bugs.python.org/issue32742>
_______________________________________


More information about the Python-bugs-list mailing list