cpython/Python
Gregory P. Smith 38f11cc3f6
bpo-1054041: Exit properly after an uncaught ^C. (#11862)
* bpo-1054041: Exit properly by a signal after a ^C.

An uncaught KeyboardInterrupt exception means the user pressed ^C and
our code did not handle it.  Programs that install SIGINT handlers are
supposed to reraise the SIGINT signal to the SIG_DFL handler in order
to exit in a manner that their calling process can detect that they
died due to a Ctrl-C.  https://www.cons.org/cracauer/sigint.html

After this change on POSIX systems

 while true; do python -c 'import time; time.sleep(23)'; done

can be stopped via a simple Ctrl-C instead of the shell infinitely
restarting a new python process.

What to do on Windows, or if anything needs to be done there has not
yet been determined.  That belongs in its own PR.

TODO(gpshead): A unittest for this behavior is still needed.

* Do the unhandled ^C check after pymain_free.

* Return STATUS_CONTROL_C_EXIT on Windows.

* Fix ifdef around unistd.h include.

* 📜🤖 Added by blurb_it.

* Add STATUS_CTRL_C_EXIT to the os module on Windows

* Add unittests.

* Don't send CTRL_C_EVENT in the Windows test.

It was causing CI systems to bail out of the entire test suite.

See https://dev.azure.com/Python/cpython/_build/results?buildId=37980
for example.

* Correct posix test (fail on macOS?) check.

* STATUS_CONTROL_C_EXIT must be unsigned.

* Improve the error message.

* test typo :)

* Skip if the bash version is too old.

...and rename the windows test to reflect what it does.

* min bash version is 4.4, detect no bash.

* restore a blank line i didn't mean to delete.

* PyErr_Occurred() before the Py_DECREF(co);

* Don't add os.STATUS_CONTROL_C_EXIT as a constant.

* Update the Windows test comment.

* Refactor common logic into a run_eval_code_obj fn.
2019-02-16 12:57:40 -08:00
..
clinic bpo-35582: Argument Clinic: Optimize the "all boring objects" case. (GH-11520) 2019-01-11 18:01:42 +02:00
Python-ast.c bpo-35766 follow-up: Kill half-support for FunctionType in PyAST_obj2mod (#11714) 2019-02-01 11:37:34 -08:00
README Issue #18093: Factor out the programs that embed the runtime 2014-07-25 21:52:14 +10:00
_warnings.c bpo-35454: Fix miscellaneous minor issues in error handling. (#11077) 2018-12-11 08:38:03 +02:00
asdl.c replace PY_SIZE_MAX with SIZE_MAX 2016-09-07 09:26:18 -07:00
ast.c bpo-35766 follow-up: Add an error check to new_type_comment() (#11766) 2019-02-11 08:10:42 -08:00
ast_opt.c bpo-33416: Add end positions to Python AST (GH-11605) 2019-01-22 11:18:22 +00:00
ast_unparse.c bpo-34854: Fix compiling string annotations containing lambdas. (GH-9645) 2018-09-30 21:07:05 +03:00
bltinmodule.c bpo-35766: Merge typed_ast back into CPython (GH-11645) 2019-01-31 12:40:27 +01:00
bootstrap_hash.c bpo-35550: Fix incorrect Solaris define guards (GH-11275) 2018-12-30 18:16:40 -08:00
ceval.c bpo-35634: Raise an error when first passed kwargs contains duplicated keys. (GH-11438) 2019-01-12 10:12:24 +02:00
ceval_gil.h bpo-35081: Add pycore_ prefix to internal header files (GH-10263) 2018-11-01 00:52:28 +01:00
codecs.c bpo-35454: Fix miscellaneous minor issues in error handling. (#11077) 2018-12-11 08:38:03 +02:00
compile.c bpo-35798: Fix duplicate SyntaxWarning: "is" with a literal. (GH-11639) 2019-02-16 08:29:46 +02:00
condvar.h bpo-35081: Add pycore_ prefix to internal header files (GH-10263) 2018-11-01 00:52:28 +01:00
context.c bpo-33029: Fix signatures of getter and setter functions. (GH-10746) 2018-11-27 19:34:35 +02:00
coreconfig.c bpo-35336: Fix PYTHONCOERCECLOCALE=1 (GH-10806) 2018-11-30 11:34:47 +01:00
dtoa.c bpo-30923: Silence fall-through warnings included in -Wextra since gcc-7.0. (#3157) 2017-08-21 13:09:59 +02:00
dup2.c bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
dynamic_annotations.c bpo-32241: Add the const qualifire to declarations of umodifiable strings. (#4748) 2017-12-12 13:55:04 +02:00
dynload_aix.c PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
dynload_dl.c Issue #24268: Fix import naming when loading extension modules. Patch by Petr Viktorin. 2015-05-23 14:13:41 -07:00
dynload_hpux.c Issue #24268: Fix import naming when loading extension modules. Patch by Petr Viktorin. 2015-05-23 14:13:41 -07:00
dynload_shlib.c bpo-28401: prevent Py_DEBUG builds from trying to import limited ABI modules (GH-1766) 2018-11-16 15:52:52 -08:00
dynload_stub.c Issue #13959: Re-implement imp.get_suffixes() in Lib/imp.py. 2012-05-04 15:20:40 -04:00
dynload_win.c bpo-33895: Relase GIL while calling functions that acquire Windows loader lock (GH-7789) 2019-02-02 09:16:42 -08:00
errors.c bpo-35081: Rename internal headers (GH-10275) 2018-11-12 16:53:38 +01:00
fileutils.c bpo-34523: Fix C locale coercion on FreeBSD CURRENT (GH-10672) 2018-11-23 13:08:26 +01:00
formatter_unicode.c bpo-33954: Fix _PyUnicode_InsertThousandsGrouping() (GH-10623) 2018-11-26 13:40:01 +01:00
frozen.c bpo-25711: Rewrite zipimport in pure Python. (GH-6809) 2018-09-18 22:22:29 +03:00
frozenmain.c bpo-35081: Rename internal headers (GH-10275) 2018-11-12 16:53:38 +01:00
future.c bpo-34683: Make SyntaxError column offsets consistently 1-indexed (gh-9338) 2018-09-24 14:12:49 -07:00
getargs.c bpo-35582: Argument Clinic: inline parsing code for positional parameters. (GH-11313) 2019-01-11 16:01:14 +02:00
getcompiler.c closes bpo-31696: don't mention GCC in sys.version when building with clang (#3891) 2017-10-05 21:15:14 -07:00
getcopyright.c Bump copyright years to 2019. (GH-11404) 2019-01-02 07:46:53 -08:00
getopt.c bpo-35081: Add pycore_ prefix to internal header files (GH-10263) 2018-11-01 00:52:28 +01:00
getplatform.c bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
getversion.c bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
graminit.c bpo-35877: Make parenthesis optional for named expression in while statement (GH-11724) 2019-02-01 14:40:16 -07:00
hamt.c bpo-35059: Cast void* to PyObject* (GH-10650) 2018-11-22 10:25:22 +01:00
import.c bpo-35470: Fix a reference counting bug in _PyImport_FindExtensionObjectEx(). (GH-11128) 2019-01-10 18:12:31 +02:00
importdl.c bpo-31315: Fix an assertion failure in imp.create_dynamic(), when spec.name is not a string. (#3257) 2017-09-19 14:39:47 +03:00
importdl.h PEP 489: Multi-phase extension module initialization 2015-05-23 22:24:10 +10:00
importlib.h bpo-35321: Set the spec origin to frozen in frozen modules (#11732) 2019-02-04 16:56:26 -08:00
importlib_external.h bpo-16806: Fix `lineno` and `col_offset` for multi-line string tokens (GH-10021) 2019-01-13 13:05:13 +09:00
importlib_zipimport.h bpo-16806: Fix `lineno` and `col_offset` for multi-line string tokens (GH-10021) 2019-01-13 13:05:13 +09:00
makeopcodetargets.py makeopcodetargets.py: we need to import Lib/opcode.py 2016-03-26 01:04:37 +01:00
marshal.c bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015) 2018-12-07 12:11:30 +02:00
modsupport.c bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716) 2017-03-30 09:15:31 +03:00
mysnprintf.c
mystrtoul.c bpo-31370: Remove support for threads-less builds (#3385) 2017-09-07 18:56:24 +02:00
opcode_targets.h bpo-33041: Rework compiling an "async for" loop. (#6142) 2018-03-23 14:34:35 +02:00
pathconfig.c bpo-35890 : Fix some API calling consistency (GH-11742) 2019-02-02 20:26:55 -08:00
peephole.c bpo-9566: Fix compiler warnings in peephole.c (GH-10652) 2018-12-07 17:54:18 +01:00
pyarena.c Fix typos in comments (GH-9905) 2018-10-19 23:30:03 +02:00
pyctype.c
pyfpe.c bpo-29137: Remove fpectl module (#4789) 2018-01-05 23:15:34 -08:00
pyhash.c bpo-31849: Fix warning in pyhash.c (GH-6799) 2018-06-04 19:57:08 +09:00
pylifecycle.c bpo-1054041: Exit properly after an uncaught ^C. (#11862) 2019-02-16 12:57:40 -08:00
pymath.c bpo-35214: Add _Py_ prefix to MEMORY_SANITIZER def. (GH-10503) 2018-11-12 22:01:22 -08:00
pystate.c bpo-35972: _xxsubinterpreters: Fix potential integer truncation on 32-bit in channel_send() (gh-11822) 2019-02-12 09:06:43 -07:00
pystrcmp.c
pystrhex.c closes bpo-34646: Remove PyAPI_* macros from declarations. (GH-9218) 2018-09-12 12:06:42 -07:00
pystrtod.c bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015) 2018-12-07 12:11:30 +02:00
pythonrun.c bpo-1054041: Exit properly after an uncaught ^C. (#11862) 2019-02-16 12:57:40 -08:00
pytime.c bpo-34373: fix test_mktime and test_pthread_getcpuclickid tests on AIX (GH-8726) 2018-12-28 23:57:37 +10:00
strdup.c bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
structmember.c Added the const qualifier to char* variables that refer to readonly internal 2016-11-20 10:16:47 +02:00
symtable.c Complete switch cases in symtable.c; fixes bpo-35963 (GH-11821) 2019-02-11 11:34:50 -08:00
sysmodule.c bpo-35890 : Fix some API calling consistency (GH-11742) 2019-02-02 20:26:55 -08:00
thread.c bpo-35081: Rename internal headers (GH-10275) 2018-11-12 16:53:38 +01:00
thread_nt.h bpo-33316: PyThread_release_lock always fails (GH-6541) 2019-02-02 08:22:55 -08:00
thread_pthread.h bpo-33015: Fix UB in pthread PyThread_start_new_thread (GH-6008) 2018-11-30 16:14:25 +01:00
traceback.c bpo-33029: Fix signatures of getter and setter functions. (GH-10746) 2018-11-27 19:34:35 +02:00
wordcode_helpers.h bpo-31338 (#3374) 2017-09-14 18:13:16 -07:00

README

Miscellaneous source files for the main Python shared library