Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix zip extraction for python 3 #25707

Merged
merged 1 commit into from Feb 10, 2020
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -187,6 +187,21 @@ def extract(self, member, path=None, pwd=None):
os.chmod(extracted, mode)
return extracted

# For Python 3.x
def _extract_member(self, member, targetpath, pwd):
if sys.version_info[0] >= 3:
if not isinstance(member, zipfile.ZipInfo):
member = self.getinfo(member)

targetpath = super()._extract_member(member, targetpath, pwd)

attr = member.external_attr >> 16
if attr != 0:
os.chmod(targetpath, attr)
return targetpath
else:
return super(ZipFileWithUnixPermissions, self)._extract_member(member, targetpath, pwd)


def extract(src, dst, movedir=None, remove=True):
assert src.endswith(".zip")
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.