Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

Python cannot run Subpars larger than 2GiB because they are Zip64 formatted. #132

@thundergolfer

Description

@thundergolfer

This is very unlikely to be fixed due to Subpar's maintenance status but it's good to document it here to potentially save others some debugging time.


Any .par written by Subpar using zipfile will be ZIP64 format whenever the file size exceeds ZIP64_LIMIT = (1 << 31) - 1. See https://github.com/python/cpython/blob/ffd87b7093109c279caf8e3ca060f408a102388a/Lib/zipfile.py#L56

As of Python 3.10 zipimport does not support ZIP64. The module function in question is _read_directory: https://github.com/python/cpython/blob/bb3e0c240bc60fe08d332ff5955d54197f79751c/Lib/zipimport.py#L408-L468

On attempting to run the subpar like python3 foo.par you will get an obscure error:

can't find '__main__' module in /foo.par

If you do python3 -vv foo.par you will see a logline:

# zipimport: found 0 names in /abs/path/to/foo.par

Python's zipimport._read_directory has failed to find any files because it has incorrectly calculated the byte offset for the first ZIP record file. It has incorrectly calculated the byte offset because it does not understand ZIP64.


So if you see this error check the size of your .par.

par_size = ...
max_bytes = (1 << 31) -1
if max_bytes < par_size:
    print("bad news")

cc @ducthienbui97 who completed this bug investigation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions