8000 bpo-12029: [doc] clarify that except does not match virtual subclasse… · python/cpython@45833b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 45833b5

Browse files
authored
bpo-12029: [doc] clarify that except does not match virtual subclasses of the specified exception type (GH-32027)
1 parent 1ea055b commit 45833b5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Doc/reference/compound_stmts.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,10 @@ is found that matches the exception. An expression-less except clause, if
243243
present, must be last; it matches any exception. For an except clause with an
244244
expression, that expression is evaluated, and the clause matches the exception
245245
if the resulting object is "compatible" with the exception. An object is
246-
compatible with an exception if the object is the class or a base class of the exception
247-
object, or a tuple containing an item that is the class or a base class of
248-
the exception object.
246+
compatible with an exception if the object is the class or a
247+
:term:`non-virtual base class <abstract base class>` of the exception object,
248+
or a tuple containing an item that is the class or a non-virtual base class
249+
of the exception object.
249250

250251
If no except clause matches the exception, the search for an exception handler
251252
continues in the surrounding code and on the invocation stack. [#]_

Doc/reference/executionmodel.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,9 @@ a stack traceback, except when the exception is :exc:`SystemExit`.
259259

260260
Exceptions are identified by class instances. The :keyword:`except` clause is
261261
selected depending on the class of the instance: it must reference the class of
262-
the instance or a base class thereof. The instance can be received by the
263-
handler and can carry additional information about the exceptional condition.
262+
the instance or a :term:`non-virtual base class <abstract base class>` thereof.
263+
The instance can be received by the handler and can carry additional information
264+
about the exceptional condition.
264265

265266
.. note::
266267

0 commit comments

Comments
 (0)
0