python / python/cpython

Support copy.replace() for zipfile.ZipInfo

Open
#155,039 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

There is no easy way to get a copy of a zipfile.ZipInfo object with some attributes changed, for example to write a member read from one archive to another under a different name.

I propose to support copy.replace():

zinfo = copy.replace(zf.getinfo('spam.txt'), filename='eggs.txt')

Attributes which are not replaced are inherited from the original object. As in the constructor, the file name is sanitized and the date is validated.

Linked PRs
  • gh-155045

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the zipfile.ZipInfo entry point and the copy.replace() protocol; no source file or test is named in the issue. Compare replacement behavior with the ZipInfo constructor, including inherited attributes, filename sanitization, and date validation. Done means a ZipInfo member can be copied with selected attributes changed and used under a different filename.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.