[issue46291] [doc] First argument to raise can also be BaseException

Andre Roberge report at bugs.python.org
Fri Jan 7 15:26:20 EST 2022


Andre Roberge <andre.roberge at gmail.com> added the comment:

Irit:

Gregor indicates that, while the tutorial refers to "a class that derives from Exception", the Python Reference Language states exceptions should be subclasses of BaseException  (which Exception *is*).

You then invited Gregor to submit a patch to change the wording of the tutorial (implying that it would refer to a class that derives from BaseException).

I pointed out that the advice given elsewhere is that user-defined exceptions should derive from Exception (thus, not from BaseException), so that nothing should be changed in the tutorial, and no change should be submitted.

So, as I understand it: there is a strict hierarchy of exceptions classes, all inheriting from BaseException. However, user-defined exceptions should be derived from Exception (and not BaseException), as indicated in the tutorial and on the page describing what each exception indicates. If that is correct, nothing needs to be changed in the tutorial.

----------

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


More information about the Python-bugs-list mailing list