Skip to content

Inconsistent behavior of zipapp.create_archive #156568

Description

@eoan-ermine

Bug report

Bug description:

Currently, zipapp.create_archive makes the target application archive executable only if target is a str. (see snippets bellow).

I think the target application archive should be made executable also when target is os.PathLike.

# source.py
print("Hello from pyz")
# bug_reproduction.py
import os
import pathlib
import zipapp
import sys

zipapp.create_archive("source.py", "source.pyz")

zipapp.create_archive(
    pathlib.Path("source.pyz"),
    pathlib.Path("copy.pyz"),
    interpreter=sys.executable,
)


zipapp.create_archive("source.pyz", "copy2.pyz", interpreter=sys.executable)

assert os.access("copy2.pyz", os.X_OK)  # Passes
assert os.access("copy.pyz", os.X_OK)  # Fails

CPython versions tested on:

CPython main branch, commit b0c9fc3

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions