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

Improve error message of subprocess when cannot open #49175

Closed
mmokrejs mannequin opened this issue Jan 12, 2009 · 8 comments
Closed

Improve error message of subprocess when cannot open #49175

mmokrejs mannequin opened this issue Jan 12, 2009 · 8 comments
Labels
easy extension-modules C modules in the Modules dir type-feature A feature request or enhancement

Comments

@mmokrejs
Copy link
Mannequin

mmokrejs mannequin commented Jan 12, 2009

BPO 4925
Nosy @terryjreedy, @amauryfa, @benjaminp, @bitdancer, @briancurtin
Files
  • issue4925.diff: now with errno.ENOENT instead of 2
  • 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 2010-11-20.18:08:24.044>
    created_at = <Date 2009-01-12.16:26:57.020>
    labels = ['extension-modules', 'easy', 'type-feature']
    title = 'Improve error message of subprocess when cannot open'
    updated_at = <Date 2010-11-20.18:29:36.043>
    user = 'https://bugs.python.org/mmokrejs'

    bugs.python.org fields:

    activity = <Date 2010-11-20.18:29:36.043>
    actor = 'brian.curtin'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-11-20.18:08:24.044>
    closer = 'benjamin.peterson'
    components = ['Extension Modules']
    creation = <Date 2009-01-12.16:26:57.020>
    creator = 'mmokrejs'
    dependencies = []
    files = ['19688']
    hgrepos = []
    issue_num = 4925
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['79684', '79685', '79697', '108644', '108895', '121678', '121700', '121701']
    nosy_count = 8.0
    nosy_names = ['terry.reedy', 'amaury.forgeotdarc', 'mmokrejs', 'benjamin.peterson', 'LambertDW', 'r.david.murray', 'brian.curtin', 'endian']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue4925'
    versions = ['Python 3.2']

    @mmokrejs
    Copy link
    Mannequin Author

    mmokrejs mannequin commented Jan 12, 2009

    I think the following error output unsatisfactory as it does not give me
    any hint what file was not found:

    $ fetch_quals.py blah.txt 
    Traceback (most recent call last):
      File "/home/mmokrejs/bin/fetch_quals.py", line 15, in <module>
        _p1 = subprocess.Popen(['query_tracedb', 'retrieve', 'quality',
    _id], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
      File "/usr/lib/python2.5/subprocess.py", line 594, in __init__
        errread, errwrite)
      File "/usr/lib/python2.5/subprocess.py", line 1091, in _execute_child
        raise child_exception
    OSError: [Errno 2] No such file or directory
    $

    I know now that I had to specify full path tot he binary or include
    shell=True argument but anyway, please improve the error message.

    @mmokrejs mmokrejs mannequin added type-bug An unexpected behavior, bug, or error extension-modules C modules in the Modules dir labels Jan 12, 2009
    @lambertdw
    Copy link
    Mannequin

    lambertdw mannequin commented Jan 12, 2009

    Related, but outside python realm, this error likewise confuses:

    $ cat <<EOF > s.sh
    #! invalid path
    echo hi
    EOF
    $ ./s.sh 
    zsh: no such file or directory: ./s.sh

    @lambertdw
    Copy link
    Mannequin

    lambertdw mannequin commented Jan 12, 2009

    (Actual command stream includes chmod +x ./s.sh)

    @terryjreedy
    Copy link
    Member

    Improved error messages are feature requests because 1) there is no particular guarantee in the doc and 2) changes can break existing code, so should only happen in an new x.y version.

    When reporting behavior, it is helpful to give *minimal* code that will reproduce, either in the message if small, or attached. For example, with 3.1.2 on WixXP

    >>> import subprocess
    >>> subprocess.Popen("xyz")
    gives
    WindowsError: [Error 2] The system cannot find the file specified

    Although in this case the literal name is in the traceback, it is not always. So I am leaving this open. Given that

    >>> open('xyx')
    gives the more helpful
    IOError: [Errno 2] No such file or directory: 'xyx'

    it seems it might be possible by using the io code.

    @terryjreedy terryjreedy changed the title Improve error message of subprocess Improve error message of subprocess when cannot open Jun 25, 2010
    @terryjreedy terryjreedy added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Jun 25, 2010
    @amauryfa
    Copy link
    Member

    in PC/_subprocess.c, it should be enough to use PyErr_SetFromWindowsErrWithFilename() instead of PyErr_SetFromWindowsErr()

    @amauryfa amauryfa added the easy label Jun 29, 2010
    @endian
    Copy link
    Mannequin

    endian mannequin commented Nov 20, 2010

    I'm working this for platforms that use OSError. #pythonbugday2010 #myfirstpatch

    @benjaminp
    Copy link
    Contributor

    r86593

    @bitdancer
    Copy link
    Member

    Note that Benjamin's commit only addresses the posix side. Amaury, do you want to fix the windows side?

    @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
    easy extension-modules C modules in the Modules dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants