Skip to content

Incorrect reading "End of central directory record." (zipfile module) #108526

@igorechek06

Description

@igorechek06

Bug report

Checklist

  • I am confident this is a bug in CPython, not a bug in a third-party project
  • I have searched the CPython issue tracker,
    and am confident this bug has not been reported before

CPython versions tested on:

3.8, 3.9, 3.11

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

No response

A clear and concise description of the bug:

This simple example fully describe this bug

from zipfile import ZipFile

with ZipFile("archive.zip", "w") as archive:
    archive.comment = b"PK\005\006" + b"\000" * 18  # Archive has a comment

    with archive.open("file1", "w") as file:  # -\
        file.write(b"content")  #                |
        #                                        |
    with archive.open("file2", "w") as file:  #  |
        file.write(b"content")  #                |- 3 files
        #                                        |
    with archive.open("file3", "w") as file:  #  |
        file.write(b"content")  #               -/

with ZipFile("archive.zip") as archive:
    assert archive.comment == b"PK\005\006" + b"\000" * 18  # Error - archie has no comment
    assert len(archive.filelist) == 3  # Error - archive has no files

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions