Branch: master
Find file History
gpshead 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.
Latest commit 38f11cc Feb 16, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
cpython bpo-35713: Rework Python initialization (GH-11647) Jan 22, 2019
internal bpo-1054041: Exit properly after an uncaught ^C. (#11862) Feb 16, 2019
Python-ast.h bpo-35766: Merge typed_ast back into CPython (GH-11645) Jan 31, 2019
Python.h bpo-28503: Use crypt_r() when available instead of crypt() (GH-11373) Dec 30, 2018
abstract.h bpo-35134: Create Include/cpython/abstract.h (GH-10728) Nov 26, 2018
asdl.h bpo-18407: ast.c uses Py_ssize_t for asdl_seq_LEN() iterator (GH-10655) Nov 22, 2018
ast.h bpo-35177: Add dependencies between header files (GH-10361) Nov 11, 2018
bitset.h bpo-32150: Expand tabs to spaces in C files. (#4583) Nov 28, 2017
bltinmodule.h these builtins have to be initialized May 9, 2009
boolobject.h #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and… Dec 19, 2007
bytearrayobject.h fix comment Oct 5, 2013
bytes_methods.h bpo-32677: Add .isascii() to str, bytes and bytearray (GH-5342) Jan 27, 2018
bytesobject.h bpo-32150: Expand tabs to spaces in C files. (#4583) Nov 28, 2017
cellobject.h bpo-32150: Expand tabs to spaces in C files. (#4583) Nov 28, 2017
ceval.h bpo-35444: Unify and optimize the helper for getting a builtin object. ( Dec 11, 2018
classobject.h bpo-32150: Expand tabs to spaces in C files. (#4583) Nov 28, 2017
code.h String annotations [PEP 563] (#4390) Jan 26, 2018
codecs.h Issue #29058: All stable API extensions added after Python 3.2 are now Dec 27, 2016
compile.h bpo-35766: Merge typed_ast back into CPython (GH-11645) Jan 31, 2019
complexobject.h Issue #21803: remove macro indirections in complexobject.h Jul 7, 2014
context.h bpo-34762: Fix contextvars C API to use PyObject* pointer types. (GH-… Sep 21, 2018
coreconfig.h bpo-35233: InitConfigTests tests more config vars (GH-10541) Nov 14, 2018
datetime.h bpo-35081: Remove Py_BUILD_CORE from datetime.h (GH-10416) Nov 13, 2018
descrobject.h bpo-32240: Add the const qualifier to declarations of PyObject* array… Dec 15, 2017
dictobject.h bpo-35134: Create Include/cpython/dictobject.h (GH-10732) Nov 26, 2018
dtoa.h Issue #14521: Make result of float('nan') and float('-nan') more cons… Apr 29, 2012
dynamic_annotations.h fix instances of consecutive articles (closes #23221) Jan 13, 2015
enumobject.h Implement and apply PEP 322, reverse iteration Nov 6, 2003
errcode.h bpo-32150: Expand tabs to spaces in C files. (#4583) Nov 28, 2017
eval.h bpo-32240: Add the const qualifier to declarations of PyObject* array… Dec 15, 2017
fileobject.h bpo-29240: PEP 540: Add a new UTF-8 Mode (#855) Dec 13, 2017
fileutils.h bpo-28604: Fix localeconv() for different LC_MONETARY (GH-10606) Nov 20, 2018
floatobject.h Issue #11734: Add support for IEEE 754 half-precision floats to the s… Sep 3, 2016
frameobject.h Move exc state to generator. Fixes bpo-25612 (#1773) Oct 22, 2017
funcobject.h bpo-32240: Add the const qualifier to declarations of PyObject* array… Dec 15, 2017
genobject.h bpo-32591: Add native coroutine origin tracking (#5250) Jan 21, 2018
graminit.h bpo-35766: Merge typed_ast back into CPython (GH-11645) Jan 31, 2019
grammar.h bpo-32150: Expand tabs to spaces in C files. (#4583) Nov 28, 2017
import.h Fix redundant declaration of _PyImport_AddModuleObject (GH-7992) Jun 29, 2018
intrcheck.h Add missed details of the C API introduced in 3.7. (GH-7047) May 22, 2018
iterobject.h Rename _PyIter_GetBuiltin to _PyObject_GetBuiltin, and do not include… Apr 4, 2012
listobject.h bpo-29867: Add asserts in PyTuple_GET_SIZE, PyList_GET_SIZE and PySet… Apr 21, 2017
longintrepr.h bpo-32150: Expand tabs to spaces in C files. (#4583) Nov 28, 2017
longobject.h bpo-20260: Implement non-bitwise unsigned int converters for Argument… Jul 26, 2018
marshal.h Issue #1772673: The type of `char*` arguments now changed to `const c… Oct 19, 2013
memoryobject.h Issue #29058: All stable API extensions added after Python 3.2 are now Dec 27, 2016
metagrammar.h REMOVED all CWI, CNRI and BeOpen copyright markings. Sep 1, 2000
methodobject.h bpo-32240: Add the const qualifier to declarations of PyObject* array… Dec 15, 2017
modsupport.h bpo-35582: Argument Clinic: inline parsing code for positional parame… Jan 11, 2019
moduleobject.h bpo-33237: Improve AttributeError message for partially initialized m… Oct 30, 2018
namespaceobject.h Issue #26900: Excluded underscored names and other private API from l… Sep 11, 2016
node.h bpo-33416: Add end positions to Python AST (GH-11605) Jan 22, 2019
object.h bpo-35134: Don't define types twice in header files (GH-10754) Nov 27, 2018
objimpl.h bpo-35134: Create Include/cpython/ subdirectory (GH-10624) Nov 23, 2018
odictobject.h bpo-35059: Add _PyObject_CAST() macro (GH-10645) Nov 22, 2018
opcode.h Update opcode.h header comment to mention the source data file (GH-9935) Oct 18, 2018
osdefs.h Issue #22591: Drop support of MS-DOS Oct 10, 2014
osmodule.h Issue #29058: All stable API extensions added after Python 3.2 are now Dec 27, 2016
parsetok.h bpo-35766: Merge typed_ast back into CPython (GH-11645) Jan 31, 2019
patchlevel.h Post 3.8.0a1 Feb 4, 2019
pgen.h Changes from Jonathan Riehl to allow his pgen extension (PEP 269) to Apr 17, 2003
pgenheaders.h bpo-32150: Expand tabs to spaces in C files. (#4583) Nov 28, 2017
py_curses.h bpo-20171: Convert the _curses and _curses_panel modules to Argument … May 10, 2018
pyarena.h Merge branches/pep-0384. Dec 3, 2010
pycapsule.h Merged revisions 88517 via svnmerge from Feb 22, 2011
pyctype.h Try to fix linking failures under Windows Oct 4, 2011
pydebug.h bpo-32125: Remove Py_UseClassExceptionsFlag flag (#4544) Nov 24, 2017
pydtrace.d bpo-31574: importlib dtrace (#3749) Sep 29, 2017
pydtrace.h bpo-35059: Remove Py_STATIC_INLINE() macro (GH-10216) Oct 29, 2018
pyerrors.h bpo-35224: PEP 572 Implementation (#10497) Jan 24, 2019
pyexpat.h bpo-34623: Use XML_SetHashSalt in _elementtree (GH-9146) Sep 18, 2018
pyfpe.h bpo-29137: Remove fpectl module (#4789) Jan 6, 2018
pyhash.h Correct the location of a function mentioned in a comment (GH-4327) Nov 9, 2017
pylifecycle.h bpo-35259: Limit `Py_FinalizeEx()` to `Py_LIMITED_API >= 0x03060000`. ( Dec 20, 2018
pymacconfig.h Minor spelling fixes Aug 20, 2016
pymacro.h bpo-31338 (#3374) Sep 15, 2017
pymath.h bpo-31373: fix undefined floating-point demotions (#3396) Sep 7, 2017
pymem.h bpo-35081: Move Py_BUILD_CORE code to internal/mem.h (GH-10249) Oct 31, 2018
pyport.h bpo-35758: Fix building on ARM + MSVC (gh-11531) Jan 21, 2019
pystate.h bpo-35134: Don't define types twice in header files (GH-10754) Nov 27, 2018
pystrcmp.h Merged revisions 59541-59561 via svnmerge from Dec 19, 2007
pystrhex.h Issue #26900: Excluded underscored names and other private API from l… Sep 11, 2016
pystrtod.h Issue #26331: Implement the parsing part of PEP 515. Sep 9, 2016
pythonrun.h bpo-22257: Small changes for PEP 432. (#1728) May 23, 2017
pythread.h bpo-30768: Recompute timeout on interrupted lock (GH-4103) Oct 24, 2017
pytime.h bpo-31784: Implement PEP 564: add time.time_ns() (#3989) Nov 2, 2017
rangeobject.h #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and… Dec 19, 2007
setobject.h bpo-29867: Add asserts in PyTuple_GET_SIZE, PyList_GET_SIZE and PySet… Apr 21, 2017
sliceobject.h bpo-32150: Expand tabs to spaces in C files. (#4583) Nov 28, 2017
structmember.h Issue #28761: The fields name and doc of structures PyMemberDef, PyGe… Nov 22, 2016
structseq.h Issue #28761: The fields name and doc of structures PyMemberDef, PyGe… Nov 22, 2016
symtable.h bpo-35224: PEP 572 Implementation (#10497) Jan 24, 2019
sysmodule.h bpo-32030: Make _PySys_AddXOptionWithError() private (GH-10236) Oct 30, 2018
token.h bpo-35766: Merge typed_ast back into CPython (GH-11645) Jan 31, 2019
traceback.h Issue #26900: Excluded underscored names and other private API from l… Sep 11, 2016
tracemalloc.h bpo-35053: Define _PyTraceMalloc_NewReference in object.h (GH-10107) Oct 25, 2018
tupleobject.h bpo-35134: Create Include/cpython/tupleobject.h (GH-10764) Nov 28, 2018
typeslots.h Issue 24365: Conditionalize PEP 489 additions to the stable ABI Jun 2, 2015
ucnhash.h Removed unintentional trailing spaces in non-external and non-generat… Mar 18, 2015
unicodeobject.h bpo-35134: Create Include/cpython/unicodeobject.h (GH-10680) Nov 26, 2018
warnings.h bpo-32591: Add native coroutine origin tracking (#5250) Jan 21, 2018
weakrefobject.h Closes #13867: remove untrue comment about PyWeakref_Check(). Oct 8, 2013