]> granicus.if.org Git - python/commit
bpo-1230540: Add threading.excepthook() (GH-13515)
authorVictor Stinner <vstinner@redhat.com>
Mon, 27 May 2019 22:39:52 +0000 (00:39 +0200)
committerGitHub <noreply@github.com>
Mon, 27 May 2019 22:39:52 +0000 (00:39 +0200)
commitcd590a7cede156a4244e7cac61e4504e5344d842
tree371aa076f7be6e942e904ebfa6aa6e7dbb2f0678
parent23b4b697e5b6cc897696f9c0288c187d2d24bff2
bpo-1230540: Add threading.excepthook() (GH-13515)

Add a new threading.excepthook() function which handles uncaught
Thread.run() exception. It can be overridden to control how uncaught
exceptions are handled.

threading.ExceptHookArgs is not documented on purpose: it should not
be used directly.

* threading.excepthook() and threading.ExceptHookArgs.
* Add _PyErr_Display(): similar to PyErr_Display(), but accept a
  'file' parameter.
* Add _thread._excepthook(): C implementation of the exception hook
  calling _PyErr_Display().
* Add _thread._ExceptHookArgs: structseq type.
* Add threading._invoke_excepthook_wrapper() which handles the gory
  details to ensure that everything remains alive during Python
  shutdown.
* Add unit tests.
Doc/library/sys.rst
Doc/library/threading.rst
Doc/whatsnew/3.8.rst
Include/internal/pycore_pylifecycle.h
Lib/test/test_threading.py
Lib/threading.py
Misc/NEWS.d/next/Library/2019-05-23-01-48-39.bpo-1230540.oKTNEQ.rst [new file with mode: 0644]
Modules/_threadmodule.c
Python/pythonrun.c