Skip to content

The default unraisablehook implementation does not print chained exceptions or recurse into exception groups #95572

Closed as not planned
@graingert

Description

@graingert

here's a demo in the repl

>>> class Foo:
...     def __del__(self):
...         raise BaseExceptionGroup("the bad", [Exception("critical debug advice here")])
... 
>>> f = Foo()
>>> del f
Exception ignored in: <function Foo.__del__ at 0x7f2f59df2200>
Traceback (most recent call last):
  File "<stdin>", line 3, in __del__
ExceptionGroup: the bad (1 sub-exception)
>>> 

@vstinner @iritkatriel I'm not sure if this is an omission or by design, but if an exception with critical debug advice is raised in an exceptiongroup during __del__ I can't see the type or error message

I expected the output to include:

  + Exception Group Traceback (most recent call last):
  |   File "<stdin>", line 1, in <module>
  | ExceptionGroup: the bad (1 sub-exception)
  +-+---------------- 1 ----------------
    | Exception: critical debug advice here
    +------------------------------------

Metadata

Metadata

Assignees

Labels

3.13bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions