Skip to content

FileNotFoundException raised by subprocess.call #69076

Closed

Description

@GeoffreyRoyer
BPO 24888
Nosy @bitdancer, @ambv, @miss-islington, @iritkatriel, @DonnaDia
PRs
  • bpo-24888: Clarify subprocess.check_call propagates exceptions if unable to start process #28018
  • [3.9] bpo-24888: Clarify subprocess.check_call propagates exceptions if unable to start process (GH-28018) #28223
  • [3.10] bpo-24888: Clarify subprocess.check_call propagates exceptions if unable to start process (GH-28018) #28224
  • 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-09-07.18:45:06.138>
    created_at = <Date 2015-08-18.14:36:31.218>
    labels = ['easy', 'type-bug', 'docs']
    title = 'FileNotFoundException raised by subprocess.call'
    updated_at = <Date 2021-09-07.18:45:06.137>
    user = 'https://bugs.python.org/GeoffreyRoyer'

    bugs.python.org fields:

    activity = <Date 2021-09-07.18:45:06.137>
    actor = 'lukasz.langa'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2021-09-07.18:45:06.138>
    closer = 'lukasz.langa'
    components = ['Documentation']
    creation = <Date 2015-08-18.14:36:31.218>
    creator = 'Geoffrey Royer'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 24888
    keywords = ['patch', 'easy']
    message_count = 11.0
    messages = ['248773', '248774', '248775', '396107', '396142', '400438', '400518', '401321', '401323', '401324', '401325']
    nosy_count = 8.0
    nosy_names = ['r.david.murray', 'docs@python', 'lukasz.langa', 'Geoffrey Royer', 'miss-islington', 'iritkatriel', 'DonnaDia', 'padmashreejha717']
    pr_nums = ['28018', '28223', '28224']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue24888'
    versions = []

    Activity

    1. GeoffreyRoyer commented on Aug 18, 2015

      GeoffreyRoyermannequin
      MannequinAuthor

      According to the documentation of the subprocess.check_call function: https://docs.python.org/3/library/subprocess.html#subprocess.check_call

      It would be nice to notify the reader that this function can raise FileNotFoundException. It is raised in case when the binary one wants to call does not exist.

      Example:

      Python 3.4.0 (default, Jun 19 2015, 14:20:21) 
      [GCC 4.8.2] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import subprocess
      >>> subprocess.check_call(["foo", "bar"])
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
        File "/usr/lib/python3.4/subprocess.py", line 552, in check_call
          retcode = call(*popenargs, **kwargs)
        File "/usr/lib/python3.4/subprocess.py", line 533, in call
          with Popen(*popenargs, **kwargs) as p:
        File "/usr/lib/python3.4/subprocess.py", line 848, in __init__
          restore_signals, start_new_session)
        File "/usr/lib/python3.4/subprocess.py", line 1446, in _execute_child
          raise child_exception_type(errno_num, err_msg)
      FileNotFoundError: [Errno 2] No such file or directory: 'foo'
    2. added
      docs
      on Aug 18, 2015
    3. bitdancer commented on Aug 18, 2015

      @bitdancer
      Member

      We don't in general document all the exceptions that can be raised by a piece of code. This could be an edge case, though. Let's see what others thing.

    4. bitdancer commented on Aug 18, 2015

      @bitdancer
      Member

      think.

    5. added
      type-bug
      on Aug 18, 2015
    6. iritkatriel commented on Jun 18, 2021

      @iritkatriel
      Member

      The FileNotFoundException exception is coming from the Popen call, and the docs for subprocess.check_call already mention that it delegates to Popen.

      There are quite a few different exceptions that Popen could raise, so I think David's general comment is valid, it would not make sense to mention just this one, or to try and list all of them.

    7. iritkatriel commented on Jun 19, 2021

      @iritkatriel
      Member

      That said, the current wording does seem to imply that only CalledProcessErrors can be raised by this function so it might be worth clarifying that other exceptions can occur if the command could not run at all (without enumerating the precise exceptions).

    8. DonnaDia commented on Aug 27, 2021

      DonnaDiamannequin
      Mannequin

      Hi, I will work on this. I will create a pull request within 3 days.

    9. padmashreejha717 commented on Aug 29, 2021

      padmashreejha717mannequin
      Mannequin

      You have to add shell=True to execute a shell command. check_output is trying to find an executable. Try this

    10. ambv commented on Sep 7, 2021

      @ambv
      Contributor

      New changeset 19a304b by DonnaDia in branch 'main':
      bpo-24888: Clarify subprocess.check_call propagates exceptions if unable to start process (GH-28018)
      19a304b

    11. ambv commented on Sep 7, 2021

      @ambv
      Contributor

      New changeset 2363910 by Miss Islington (bot) in branch '3.9':
      bpo-24888: Clarify subprocess.check_call propagates exceptions if unable to start process (GH-28018) (GH-28223)
      2363910

    12. miss-islington commented on Sep 7, 2021

      @miss-islington
      Contributor

      New changeset 31be544 by Miss Islington (bot) in branch '3.10':
      bpo-24888: Clarify subprocess.check_call propagates exceptions if unable to start process (GH-28018)
      31be544

    13. ambv commented on Sep 7, 2021

      @ambv
      Contributor

      Thanks for the patch, DonnaDia! ✨ 🍰 ✨

    14. 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

      docseasytype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions