Skip to content

gh-151824: Add copy() to ZipFile - #151825

Open
danny0838 wants to merge 2 commits into
python:mainfrom
danny0838:gh-51067-3
Open

gh-151824: Add copy() to ZipFile#151825
danny0838 wants to merge 2 commits into
python:mainfrom
danny0838:gh-51067-3

Conversation

@danny0838

@danny0838danny0838 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Following the remove() and repack() introduced by #134627, add copy() for performant member copying in a ZIP file.

Moving a member can also be done as a combination of copy(), remove(), and repack() like:

withZipFile('spam.zip', 'a') asmyzip:
myzip.repack([myzip.remove(myzip.copy('old.txt', 'new.txt'))])

which is required since the filename is stored within the member's local file entry and thus need a gross rewriting.

@read-the-docs-community

read-the-docs-communityBot commented Jun 21, 2026

Copy link
Copy Markdown

@danny0838

Copy link
Copy Markdown
ContributorAuthor

Nicely ping related reviewers in the previous PR: @gpshead, @merwok, @jaraco, @emmatyping, @AA-Turner.

Comment threadDoc/library/zipfile.rst
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@danny0838@picnixz