Skip to content

gh-159354: Validate explicit main arguments in zipapp - #159355

Draft
esadomer wants to merge 2 commits into
python:mainfrom
esadomer:fix-20261013-17-zipapp-main-archive-copy
Draft

esadomer wants to merge 2 commits into
python:mainfrom
esadomer:fix-20261013-17-zipapp-main-archive-copy

Conversation

@esadomer

@esadomer esadomer commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

create_archive() silently ignores main when copying an existing archive. Reject any value other than None before copying so invalid calls preserve their destination.

Apply the same distinction when creating an archive from a directory: an empty main is an explicit, invalid entry point, including when __main__.py already exists. The CLI also rejects an empty --main when copying without producing a traceback.

Validation (Windows debug build): test_zipapp passed (36 tests run, 2 skipped). The two directory cases and CLI case failed before the corresponding fixes. Coverage includes path and file-object archive sources, valid/default entry points, and destination preservation. Ruff and git diff --check passed.

Fixes #159354.

@esadomer esadomer changed the title gh-159354: Reject main when copying an existing zipapp archive gh-159354: Validate explicit main arguments in zipapp Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reject main when copying an existing zipapp archive

1 participant