Skip to content

Support copy.replace() for zipfile.ZipInfo #155039

Description

@serhiy-storchaka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    Status
    No status
    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions