Skip to content

shutil.which: does not find path/cmd.ext where ext is not given #88436

Closed

Description

@scivision
mannequin
BPO 44270
Nosy @eryksun, @scivision
PRs
  • bpo-44270: shutil.which: windows path/cmd searches pathext #26458
  • Superseder
  • bpo-24505: shutil.which wrong result on Windows
  • 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 = <Date 2021-05-31.02:51:06.833>
    created_at = <Date 2021-05-31.02:15:53.119>
    labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
    title = 'shutil.which: does not find path/cmd.ext where ext is not given'
    updated_at = <Date 2021-05-31.02:51:06.829>
    user = 'https://github.com/scivision'

    bugs.python.org fields:

    activity = <Date 2021-05-31.02:51:06.829>
    actor = 'eryksun'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-05-31.02:51:06.833>
    closer = 'eryksun'
    components = ['Library (Lib)']
    creation = <Date 2021-05-31.02:15:53.119>
    creator = 'michael2'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44270
    keywords = ['patch']
    message_count = 3.0
    messages = ['394784', '394785', '394786']
    nosy_count = 2.0
    nosy_names = ['eryksun', 'michael2']
    pr_nums = ['26458']
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '24505'
    type = 'behavior'
    url = 'https://bugs.python.org/issue44270'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. scivision commented on May 31, 2021

      scivisionmannequin
      MannequinAuthor

      The early short-circuit logic in shutil.which() when cmd includes a directory component incorrectly gives None on Windows if the correct filename suffix was not also given.

      Example: on Windows if ./foo.exe exists, then shutil.which('./foo.exe') returns None.

    2. added
      3.11only security fixes
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on May 31, 2021
    3. scivision commented on May 31, 2021

      scivisionmannequin
      MannequinAuthor

      Correction:

      Example: on Windows if ./foo.exe exists, then shutil.which('./foo') returns None.

    4. eryksun commented on May 31, 2021

      @eryksun
      Contributor

      Michael, thank you for the PR, but please associate it with the existing issue bpo-24505.

    5. 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.10 (EOL)end of life3.11only security fixes3.9 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions