Skip to content

FileNotFound error raised by os.exec* doesn't contain filename #84687

Closed

Description

@russelldavis
BPO 40507
Nosy @taleinat, @russelldavis
PRs
  • gh-84687: Add filename to the error raised by os.exec* #19915
  • 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-05-05.05:56:58.273>
    labels = ['type-feature', 'library', '3.10']
    title = "FileNotFound error raised by os.exec* doesn't contain filename"
    updated_at = <Date 2020-10-18.09:16:10.645>
    user = 'https://github.com/russelldavis'

    bugs.python.org fields:

    activity = <Date 2020-10-18.09:16:10.645>
    actor = 'taleinat'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2020-05-05.05:56:58.273>
    creator = 'russelldavis'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 40507
    keywords = ['patch']
    message_count = 3.0
    messages = ['368106', '378835', '378857']
    nosy_count = 2.0
    nosy_names = ['taleinat', 'russelldavis']
    pr_nums = ['19915']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue40507'
    versions = ['Python 3.10']

    Activity

    1. russelldavis commented on May 5, 2020

      russelldavismannequin
      MannequinAuthor

      To repro:

      >>> import os, sys
      >>> os.execv("nosuchfile", ["nosuchfile"])
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      FileNotFoundError: [Errno 2] No such file or directory
      >>> print(sys.last_value.filename)
      None
    2. taleinat commented on Oct 17, 2020

      @taleinat
      Contributor

      I agree that having the error message include the executable name could be useful.

    3. added
      type-featureA feature request or enhancement
      and removed on Oct 17, 2020
    4. 2 remaining items

    5. added
      type-featureA feature request or enhancement
      and removed on Oct 17, 2020
    6. taleinat commented on Oct 18, 2020

      @taleinat
      Contributor

      After further reading, especially the docs for OSError which describe the filename and filename2 attributes, I agree that setting .filename on the FileNotFoundError exception is the way to go.

    7. transferred this issue fromon Apr 10, 2022
    8. added
      3.13only security fixes
      and removed on May 15, 2023
    9. added
      3.16new features, bugs and security fixes
      and removed
      3.13only security fixes
      on Aug 11, 2026
    10. added a commit that references this issue on Aug 11, 2026
    11. added a commit that references this issue on Aug 14, 2026
    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.16new features, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions