Skip to content

Commit

Permalink
pythongh-117597: Clarify exception handling in the tutorial (python#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
nineteendo authored Apr 9, 2024
1 parent ca75915 commit a05068d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Doc/tutorial/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ may name multiple exceptions as a parenthesized tuple, for example::
... except (RuntimeError, TypeError, NameError):
... pass

A class in an :keyword:`except` clause is compatible with an exception if it is
the same class or a base class thereof (but not the other way around --- an
*except clause* listing a derived class is not compatible with a base class).
A class in an :keyword:`except` clause matches exceptions which are instances of the
class itself or one of its derived classes (but not the other way around --- an
*except clause* listing a derived class does not match instances of its base classes).
For example, the following code will print B, C, D in that order::

class B(Exception):
Expand Down

0 comments on commit a05068d

Please sign in to comment.