exceptiongroup icon indicating copy to clipboard operation
exceptiongroup copied to clipboard

exception information missing from unraisable exceptiongroups

Open graingert opened this issue 3 years ago • 6 comments

https://github.com/python/cpython/issues/95572

Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import exceptiongroup
>>> class Foo:
...     def __del__(self):
...         raise exceptiongroup.BaseExceptionGroup("the bad", [Exception("critical debug information")])
... 
>>> f = Foo()
>>> del f
Exception ignored in: <function Foo.__del__ at 0x7f5823e49870>
Traceback (most recent call last):
  File "<stdin>", line 3, in __del__
exceptiongroup.ExceptionGroup: the bad (1 sub-exception)

graingert avatar Aug 02 '22 14:08 graingert

this is particularly irritating in the backport because we can't just fix the default unraisable hook

graingert avatar Aug 02 '22 14:08 graingert

Can we fix this at all then?

agronholm avatar Aug 02 '22 14:08 agronholm

we could offer a fixed version of sys.unraisablehook that people could install?

graingert avatar Aug 02 '22 14:08 graingert

Maybe, when installing the normal exception hook we could check if sys.unraisablehook has been modified, and if it hasn't, install our own.

agronholm avatar Aug 02 '22 15:08 agronholm

Hmm...what should the output look like?

agronholm avatar Aug 18 '22 14:08 agronholm

Best I could do so far was:

Exception ignored in: <function Foo.__del__ at 0x7f30a6f85fc0>
  File "/home/alex/workspace/exceptiongroup/exctest3.py", line 9, in __del__
    raise ExceptionGroup(
  + Exception Group Traceback (most recent call last):
  |   File "/home/alex/workspace/exceptiongroup/exctest3.py", line 9, in __del__
  |     raise ExceptionGroup(
  | exceptiongroup.ExceptionGroup: the bad (1 sub-exception)
  +-+---------------- 1 ----------------
    | Exception: critical debug information
    +------------------------------------

agronholm avatar Aug 18 '22 14:08 agronholm