Skip to content

zipfile.ZipInfo._compresslevel should be public. #113971

Closed
@gpshead

Description

@gpshead

Feature or enhancement

Proposal:

Today people pass ZipInfo instances into APIs that accept them such as ZipFile.writestr() in order to control how individual items are put into a zip archive as such:

    zip_info = zipfile.ZipInfo(filename=filename, date_time=desired_timestamp)
    zip_info.compress_type = this_files_compress_type
    # This attribute is sadly not public; manual creation of ZipInfo objects
    # is uncommon.  Without this we cannot write compressed files with our
    # own overridden info.
    zip_info._compresslevel = this_files_compress_level  # pylint: disable=protected-access
    zip_info.external_attr = desired_permissions
    zip_file.writestr(zip_info, data)

There is no reason for ._compresslevel to be protected with an _. We should make it public as it is useful.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

Labels

3.13bugs and security fixestype-featureA feature request or enhancement

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions