Skip to content

zipimport.zipimporter breaks for zips containing files with size > 0xFFFFFFFF #118107

Description

@jsirois

Bug report

Bug description:

The following test in the Pex project fails under CPython 3.13.0a6:
https://github.com/pex-tool/pex/blob/27c2db2bf26039bef41323c964bc4e0317a7b4f5/tests/test_pex_builder.py#L520-L547

The failure includes stderr output from zipimporter like:

Failed checking if argv[0] is an import path entry
Traceback (most recent call last):
  File "<frozen zipimport>", line 98, in __init__
  File "<frozen zipimport>", line 520, in _read_directory
NameError: name 'struct' is not defined. Did you forget to import 'struct'?
  File "/tmp/pytest-of-jsirois/pytest-14/test_check0/too-big.pyz", line 1
    PK-
SyntaxError: source code cannot contain null bytes

Inspection of #94146 indicates the code added to handle too large files is missing an import: https://github.com/python/cpython/pull/94146/files#r1572552939 The tests added in that PR do stress too many files for a 32 bit zip, but they do not stress too big a file for a 32 bit zip; so it makes sense that this import omission slipped past.

CPython versions tested on:

3.13, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixesrelease-blockertype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions