exceptiongroup
exceptiongroup copied to clipboard
exception information missing from unraisable exceptiongroups
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)
this is particularly irritating in the backport because we can't just fix the default unraisable hook
Can we fix this at all then?
we could offer a fixed version of sys.unraisablehook that people could install?
Maybe, when installing the normal exception hook we could check if sys.unraisablehook has been modified, and if it hasn't, install our own.
Hmm...what should the output look like?
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
+------------------------------------