]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-117597: Clarify exception handling in the tutorial (#117681)
authorNice Zombies <nineteendo19d0@gmail.com>
Tue, 9 Apr 2024 20:59:45 +0000 (22:59 +0200)
committerGitHub <noreply@github.com>
Tue, 9 Apr 2024 20:59:45 +0000 (20:59 +0000)
Doc/tutorial/errors.rst

index 0b9acd00fdc6bd02c5ec0bb6ea687543d78d14b6..981b14f5a4212b1b551c73ccbca8906fdc43a6fe 100644 (file)
@@ -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):