• Victor Stinner's avatar
    bpo-36829: Add sys.unraisablehook() (GH-13187) · ef9d9b63
    Victor Stinner authored
    Add new sys.unraisablehook() function which can be overridden to
    control how "unraisable exceptions" are handled. It is called when an
    exception has occurred but there is no way for Python to handle it.
    For example, when a destructor raises an exception or during garbage
    collection (gc.collect()).
    
    Changes:
    
    * Add an internal UnraisableHookArgs type used to pass arguments to
      sys.unraisablehook.
    * Add _PyErr_WriteUnraisableDefaultHook().
    * The default hook now ignores exception on writing the traceback.
    * test_sys now uses unittest.main() to automatically discover tests:
      remove test_main().
    * Add _PyErr_Init().
    * Fix PyErr_WriteUnraisable(): hold a strong reference to sys.stderr
      while using it
    ef9d9b63
2019-05-08-12-51-37.bpo-36829.8enFMA.rst 311 Bytes