Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile_file's stripdir does not accept pathlib.Path #84627

Closed
hauntsaninja opened this issue Apr 30, 2020 · 2 comments
Closed

compile_file's stripdir does not accept pathlib.Path #84627

hauntsaninja opened this issue Apr 30, 2020 · 2 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir topic-pathlib type-bug An unexpected behavior, bug, or error

Comments

@hauntsaninja
Copy link
Contributor

BPO 40447
Nosy @tirkarthi, @FFY00, @hauntsaninja
PRs
  • bpo-40447: accept all path-like objects in compileall.compile_file #19883
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2020-04-30.06:18:15.892>
    labels = ['type-bug', 'library', '3.9']
    title = "compile_file's stripdir does not accept pathlib.Path"
    updated_at = <Date 2020-05-03.12:55:07.004>
    user = 'https://github.com/hauntsaninja'

    bugs.python.org fields:

    activity = <Date 2020-05-03.12:55:07.004>
    actor = 'FFY00'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-04-30.06:18:15.892>
    creator = 'hauntsaninja'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40447
    keywords = ['patch']
    message_count = 2.0
    messages = ['367740', '367741']
    nosy_count = 3.0
    nosy_names = ['xtreak', 'FFY00', 'hauntsaninja']
    pr_nums = ['19883']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue40447'
    versions = ['Python 3.9']

    @hauntsaninja
    Copy link
    Contributor Author

    Python 3.9 added the stripdir argument to compileall functions. From https://docs.python.org/3.9/library/compileall.html#compileall.compile_file:

    The stripdir, prependdir and limit_sl_dest arguments correspond to the -s, -p and -e options described above. They may be specified as str, bytes or os.PathLike.

    ~ λ python3.9
    Python 3.9.0a6+ (heads/master:360371f, Apr 29 2020, 15:44:56) 
    [Clang 11.0.0 (clang-1100.0.33.17)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import compileall, pathlib
    >>> compileall.compile_file(pathlib.Path("tmp/test.py"), stripdir=pathlib.Path("tmp"))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/Users/shantanu/.pyenv/versions/3.9-dev/lib/python3.9/compileall.py", line 161, in compile_file
        stripdir_parts = stripdir.split(os.path.sep)
    AttributeError: 'PosixPath' object has no attribute 'split'
    

    Found by Jelle Zijlstra in python/typeshed#3956 (comment)

    @hauntsaninja hauntsaninja added 3.9 only security fixes stdlib Python modules in the Lib dir labels Apr 30, 2020
    @hauntsaninja
    Copy link
    Contributor Author

    If it helps triage, this is the BPO for where the changes to compileall were made: https://bugs.python.org/issue38112

    @tirkarthi tirkarthi added type-bug An unexpected behavior, bug, or error labels Apr 30, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir topic-pathlib type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants