[issue46431] Trouble subclassing ExceptionGroup

Irit Katriel report at bugs.python.org
Wed Jan 19 08:38:49 EST 2022


Irit Katriel <iritkatriel at gmail.com> added the comment:

We probably do need better documentation for subclassing ExceptionGroup.

When you subclass an ExceptionGroup you want to make sure that split() and subgroup() (which are used by except*) will continue working, usually by defining a derive() method:

https://docs.python.org/3.11/library/exceptions.html#BaseExceptionGroup.derive

If you don't define derive the superclass constructor is used, which means you get something of type ExceptionGroup, not your subclass.


I don't know whether it's a good idea to make it easier to define a subclass that doesn't support split()/except* because ti changes the constructor signature without providing derive().

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46431>
_______________________________________


More information about the Python-bugs-list mailing list