Skip to content

Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module) #85768

Description

@graingert
mannequin
BPO 41602
Nosy @gvanrossum, @gpshead, @ncoghlan, @ambv, @eryksun, @graingert
PRs
  • bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module #21956
  • [3.9] bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (GH-21956) #22397
  • [3.8] bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (GH-21956) #22398
  • Files
  • test_exit.py
  • test_exit.txt
  • test_exit_runpy.py
  • test_exit_command_stdin.py
  • 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 2020-09-22.15:53:35.762>
    created_at = <Date 2020-08-20.19:58:37.660>
    labels = ['interpreter-core', 'type-bug', '3.8', '3.9', '3.10']
    title = "Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)"
    updated_at = <Date 2020-10-05.16:10:20.261>
    user = 'https://github.com/graingert'

    bugs.python.org fields:

    activity = <Date 2020-10-05.16:10:20.261>
    actor = 'lukasz.langa'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-09-22.15:53:35.762>
    closer = 'gvanrossum'
    components = ['Interpreter Core']
    creation = <Date 2020-08-20.19:58:37.660>
    creator = 'graingert'
    dependencies = []
    files = ['49414', '49415', '49416', '49417']
    hgrepos = []
    issue_num = 41602
    keywords = ['patch']
    message_count = 22.0
    messages = ['375732', '375733', '375735', '375736', '375775', '375898', '376984', '377000', '377012', '377013', '377014', '377019', '377020', '377021', '377022', '377024', '377027', '377028', '377339', '377447', '377451', '378057']
    nosy_count = 6.0
    nosy_names = ['gvanrossum', 'gregory.p.smith', 'ncoghlan', 'lukasz.langa', 'eryksun', 'graingert']
    pr_nums = ['21956', '22397', '22398']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue41602'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    Activity

    1. graingert commented on Aug 20, 2020

      graingertmannequin
      MannequinAuthor

      when running "python -m ham.py" KeyboardInterrupt should result in -2, but results in 1

      see test case

    2. graingert commented on Aug 20, 2020

      graingertmannequin
      MannequinAuthor
    3. graingert commented on Aug 20, 2020

      graingertmannequin
      MannequinAuthor

      I think I've eliminated runpy.py, as I still get a -2 when using:

      import runpy
      runpy.run_module("ham")

      or

      runpy._run_module_as_main("ham")

      see attached test_exit_runpy.py

      It seems the only difference is if pymain_run_file or pymain_run_module is used.

    4. changed the title [-]Python doesn't exit with proper resultcode on SIGINT in runpy[/-] [+]Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)[/+] on Aug 20, 2020
    5. changed the title [-]Python doesn't exit with proper resultcode on SIGINT in runpy[/-] [+]Python doesn't exit with proper resultcode on SIGINT in runpy (pymain_run_module)[/+] on Aug 20, 2020
    6. graingert commented on Aug 20, 2020

      graingertmannequin
      MannequinAuthor

      I've now eliminated pymain_run_stdin and pymain_run_command, both process a KeyboardInterrupt as -2

      see attached test_exit_command_stdin.py

    7. graingert commented on Aug 21, 2020

      graingertmannequin
      MannequinAuthor

      adding vstinner, as this seems related to pymain_run_module rather than runpy

    8. 11 remaining items

    9. graingert commented on Sep 16, 2020

      graingertmannequin
      MannequinAuthor

      I pushed that patch

    10. gvanrossum commented on Sep 16, 2020

      @gvanrossum
      Member

      Why did you remove 3.10?

    11. graingert commented on Sep 16, 2020

      graingertmannequin
      MannequinAuthor

      nice the tests pass with that fix

    12. gvanrossum commented on Sep 22, 2020

      @gvanrossum
      Member

      New changeset a68a2ad by Thomas Grainger in branch 'master':
      bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (bpo-21956)
      a68a2ad

    13. ambv commented on Sep 24, 2020

      @ambv
      Contributor

      New changeset ca8d46d by Łukasz Langa in branch '3.9':
      [3.9] bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (GH-21956) (bpo-22397)
      ca8d46d

    14. ambv commented on Sep 24, 2020

      @ambv
      Contributor

      New changeset ae46229 by Thomas Grainger in branch '3.8':
      [3.8] bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (GH-21956) (bpo-22398)
      ae46229

    15. ambv commented on Oct 5, 2020

      @ambv
      Contributor

      New changeset c26a666 by Łukasz Langa in branch '3.9':
      [3.9] bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (GH-21956) (bpo-22397)
      c26a666

    16. 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.8 (EOL)end of life3.9 (EOL)end of lifeinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions