10000 bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module by graingert · Pull Request #21956 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module #21956

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

Merged
merged 11 commits into from
Sep 22, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check for STATUS_CONTROL_C_EXIT on windows
  • Loading branch information
graingert committed Aug 25, 2020
commit ce4601a1dda21a8facf02554004dfcc58300898c
9 changes: 8 additions & 1 deletion Lib/test/test_runpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pathlib
import py_compile
import re
import signal
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -755,6 +756,12 @@ def test_encoding(self):


class TestExit(unittest.TestCase):
STATUS_CONTROL_C_EXIT = 0xC000013A
EXPECTED_CODE = (
STATUS_CONTROL_C_EXIT
if sys.platform == "win32"
else -signal.SIGINT
)
@staticmethod
@contextlib.contextmanager
def tmp_path(*args, **kwargs):
Expand All @@ -777,7 +784,7 @@ def run(self, *args, **kwargs):
def assertSigInt(self, *args, **kwargs):
proc = subprocess.run(*args, **kwargs, text=True, stderr=subprocess.PIPE)
self.assertTrue(proc.stderr.endswith("\nKeyboardInterrupt\n"))
self.assertEqual(proc.returncode, -2)
self.assertEqual(proc.returncode, self.EXPECTED_CODE)

def test_pymain_run_file(self):
self.assertSigInt([sys.executable, self.ham])
Expand Down
0