Skip to content

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

Description

@hauntsaninja
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']

    Activity

    1. hauntsaninja commented on Apr 30, 2020

      @hauntsaninja
      ContributorAuthor

      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)

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Apr 30, 2020
    3. hauntsaninja commented on Apr 30, 2020

      @hauntsaninja
      ContributorAuthor

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

    4. transferred this issue fromon Apr 10, 2022
    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.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytopic-pathlibtype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions