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

@danny0838 danny0838 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:

with ZipFile('spam.zip', 'a') as myzip:
    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-community Bot commented Jun 21, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33234086 | 📁 Comparing 544f13c against main (1b9fe5c)

  🔍 Preview build  

3 files changed
± library/zipfile.html
± whatsnew/3.16.html
± whatsnew/changelog.html

@danny0838

Copy link
Copy Markdown
Contributor Author

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

Comment thread Doc/library/zipfile.rst
@danny0838 danny0838 requested a review from AA-Turner as a code owner June 21, 2026 07:33
@picnixz picnixz requested review from emmatyping and jaraco June 21, 2026 07:42
Sign up for free to 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