Mailing List Archive

gh-117597: Clarify exception handling in the tutorial (#117681)
https://github.com/python/cpython/commit/a05068db0cb43337d20a936d919b9d88c35d9818
commit: a05068db0cb43337d20a936d919b9d88c35d9818
branch: main
author: Nice Zombies <nineteendo19d0@gmail.com>
committer: iritkatriel <1055913+iritkatriel@users.noreply.github.com>
date: 2024-04-09T20:59:45Z
summary:

gh-117597: Clarify exception handling in the tutorial (#117681)

files:
M Doc/tutorial/errors.rst

diff --git a/Doc/tutorial/errors.rst b/Doc/tutorial/errors.rst
index 0b9acd00fdc6bd..981b14f5a4212b 100644
--- a/Doc/tutorial/errors.rst
+++ b/Doc/tutorial/errors.rst
@@ -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):

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-leave@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: list-python-checkins@lists.gossamer-threads.com