cpython/Include
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
..
cpython bpo-35713: Rework Python initialization (GH-11647) 2019-01-22 17:39:03 +01:00
internal bpo-1054041: Exit properly after an uncaught ^C. (#11862) 2019-02-16 12:57:40 -08:00
Python-ast.h bpo-35766: Merge typed_ast back into CPython (GH-11645) 2019-01-31 12:40:27 +01:00
Python.h bpo-28503: Use crypt_r() when available instead of crypt() (GH-11373) 2018-12-30 15:42:32 -08:00
abstract.h bpo-35134: Create Include/cpython/abstract.h (GH-10728) 2018-11-26 22:42:04 +01:00
asdl.h bpo-18407: ast.c uses Py_ssize_t for asdl_seq_LEN() iterator (GH-10655) 2018-11-22 14:45:16 +01:00
ast.h bpo-35177: Add dependencies between header files (GH-10361) 2018-11-12 00:56:19 +01:00
bitset.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
bltinmodule.h
boolobject.h
bytearrayobject.h
bytes_methods.h bpo-32677: Add .isascii() to str, bytes and bytearray (GH-5342) 2018-01-27 14:06:21 +09:00
bytesobject.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
cellobject.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
ceval.h bpo-35444: Unify and optimize the helper for getting a builtin object. (GH-11047) 2018-12-11 08:28:18 +02:00
classobject.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
code.h String annotations [PEP 563] (#4390) 2018-01-26 08:20:18 -08:00
codecs.h
compile.h bpo-35766: Merge typed_ast back into CPython (GH-11645) 2019-01-31 12:40:27 +01:00
complexobject.h
context.h bpo-34762: Fix contextvars C API to use PyObject* pointer types. (GH-9473) 2018-09-21 15:33:56 -04:00
coreconfig.h bpo-35233: InitConfigTests tests more config vars (GH-10541) 2018-11-14 17:39:45 +01:00
datetime.h bpo-35081: Remove Py_BUILD_CORE from datetime.h (GH-10416) 2018-11-13 09:02:25 +01:00
descrobject.h bpo-32240: Add the const qualifier to declarations of PyObject* array arguments. (#4746) 2017-12-15 13:11:11 +02:00
dictobject.h bpo-35134: Create Include/cpython/dictobject.h (GH-10732) 2018-11-27 00:12:26 +01:00
dtoa.h
dynamic_annotations.h
enumobject.h
errcode.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
eval.h bpo-32240: Add the const qualifier to declarations of PyObject* array arguments. (#4746) 2017-12-15 13:11:11 +02:00
fileobject.h bpo-29240: PEP 540: Add a new UTF-8 Mode (#855) 2017-12-13 12:29:09 +01:00
fileutils.h bpo-28604: Fix localeconv() for different LC_MONETARY (GH-10606) 2018-11-20 16:20:16 +01:00
floatobject.h
frameobject.h Move exc state to generator. Fixes bpo-25612 (#1773) 2017-10-22 23:41:51 +02:00
funcobject.h bpo-32240: Add the const qualifier to declarations of PyObject* array arguments. (#4746) 2017-12-15 13:11:11 +02:00
genobject.h bpo-32591: Add native coroutine origin tracking (#5250) 2018-01-21 09:44:07 -05:00
graminit.h bpo-35766: Merge typed_ast back into CPython (GH-11645) 2019-01-31 12:40:27 +01:00
grammar.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
import.h Fix redundant declaration of _PyImport_AddModuleObject (GH-7992) 2018-06-29 16:47:18 -06:00
intrcheck.h Add missed details of the C API introduced in 3.7. (GH-7047) 2018-05-22 20:59:42 +03:00
iterobject.h
listobject.h bpo-29867: Add asserts in PyTuple_GET_SIZE, PyList_GET_SIZE and PySet_GET_SIZE. (#751) 2017-04-22 01:48:11 +02:00
longintrepr.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
longobject.h bpo-20260: Implement non-bitwise unsigned int converters for Argument Clinic. (GH-8434) 2018-07-26 13:22:16 +03:00
marshal.h
memoryobject.h
metagrammar.h
methodobject.h bpo-32240: Add the const qualifier to declarations of PyObject* array arguments. (#4746) 2017-12-15 13:11:11 +02:00
modsupport.h bpo-35582: Argument Clinic: inline parsing code for positional parameters. (GH-11313) 2019-01-11 16:01:14 +02:00
moduleobject.h bpo-33237: Improve AttributeError message for partially initialized module. (GH-6398) 2018-10-30 13:19:51 +02:00
namespaceobject.h
node.h bpo-33416: Add end positions to Python AST (GH-11605) 2019-01-22 11:18:22 +00:00
object.h bpo-35134: Don't define types twice in header files (GH-10754) 2018-11-27 23:54:59 +01:00
objimpl.h bpo-35134: Create Include/cpython/ subdirectory (GH-10624) 2018-11-23 17:00:00 +01:00
odictobject.h bpo-35059: Add _PyObject_CAST() macro (GH-10645) 2018-11-22 02:57:29 +01:00
opcode.h Update opcode.h header comment to mention the source data file (GH-9935) 2018-10-18 14:53:18 -05:00
osdefs.h
osmodule.h
parsetok.h bpo-35766: Merge typed_ast back into CPython (GH-11645) 2019-01-31 12:40:27 +01:00
patchlevel.h Post 3.8.0a1 2019-02-04 09:39:24 +01:00
pgen.h
pgenheaders.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
py_curses.h bpo-20171: Convert the _curses and _curses_panel modules to Argument Clinic. (GH-4251) 2018-05-10 11:27:23 +03:00
pyarena.h
pycapsule.h
pyctype.h
pydebug.h bpo-32125: Remove Py_UseClassExceptionsFlag flag (#4544) 2017-11-24 22:06:38 +01:00
pydtrace.d bpo-31574: importlib dtrace (#3749) 2017-09-29 15:53:19 -07:00
pydtrace.h bpo-35059: Remove Py_STATIC_INLINE() macro (GH-10216) 2018-10-29 14:49:24 +01:00
pyerrors.h bpo-35224: PEP 572 Implementation (#10497) 2019-01-24 16:49:56 -07:00
pyexpat.h bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146) 2018-09-18 05:38:58 -07:00
pyfpe.h bpo-29137: Remove fpectl module (#4789) 2018-01-05 23:15:34 -08:00
pyhash.h Correct the location of a function mentioned in a comment (GH-4327) 2017-11-09 19:55:34 +03:00
pylifecycle.h bpo-35259: Limit `Py_FinalizeEx()` to `Py_LIMITED_API >= 0x03060000`. (GH-10620) 2018-12-20 23:11:03 +02:00
pymacconfig.h
pymacro.h bpo-31338 (#3374) 2017-09-14 18:13:16 -07:00
pymath.h bpo-31373: fix undefined floating-point demotions (#3396) 2017-09-07 11:13:59 -07:00
pymem.h bpo-35081: Move Py_BUILD_CORE code to internal/mem.h (GH-10249) 2018-10-31 20:19:24 +01:00
pyport.h bpo-35758: Fix building on ARM + MSVC (gh-11531) 2019-01-21 21:49:40 +01:00
pystate.h bpo-35134: Don't define types twice in header files (GH-10754) 2018-11-27 23:54:59 +01:00
pystrcmp.h
pystrhex.h
pystrtod.h
pythonrun.h bpo-22257: Small changes for PEP 432. (#1728) 2017-05-22 21:36:03 -07:00
pythread.h bpo-30768: Recompute timeout on interrupted lock (GH-4103) 2017-10-24 16:53:32 -07:00
pytime.h bpo-31784: Implement PEP 564: add time.time_ns() (#3989) 2017-11-02 07:28:27 -07:00
rangeobject.h
setobject.h bpo-29867: Add asserts in PyTuple_GET_SIZE, PyList_GET_SIZE and PySet_GET_SIZE. (#751) 2017-04-22 01:48:11 +02:00
sliceobject.h bpo-32150: Expand tabs to spaces in C files. (#4583) 2017-11-28 17:56:10 +02:00
structmember.h
structseq.h
symtable.h bpo-35224: PEP 572 Implementation (#10497) 2019-01-24 16:49:56 -07:00
sysmodule.h bpo-32030: Make _PySys_AddXOptionWithError() private (GH-10236) 2018-10-30 14:31:42 +01:00
token.h bpo-35766: Merge typed_ast back into CPython (GH-11645) 2019-01-31 12:40:27 +01:00
traceback.h
tracemalloc.h bpo-35053: Define _PyTraceMalloc_NewReference in object.h (GH-10107) 2018-10-26 00:01:56 +02:00
tupleobject.h bpo-35134: Create Include/cpython/tupleobject.h (GH-10764) 2018-11-28 13:01:32 +01:00
typeslots.h
ucnhash.h
unicodeobject.h bpo-35134: Create Include/cpython/unicodeobject.h (GH-10680) 2018-11-26 17:29:38 +01:00
warnings.h bpo-32591: Add native coroutine origin tracking (#5250) 2018-01-21 09:44:07 -05:00
weakrefobject.h