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

Skip to content

Commit 7fc1254

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

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
@@ -233,9 +233,10 @@ is found that matches the exception. An expression-less except clause, if
233233
present, must be last; it matches any exception. For an except clause with an
234234
expression, that expression is evaluated, and the clause matches the exception
235235
if the resulting object is "compatible" with the exception. An object is
236-
compatible with an exception if it is the class or a base class of the exception
237-
object, or a tuple containing an item that is the class or a base class of
238-
the exception object.
236+
compatible with an exception if the object is the class or a
237+
:term:`non-virtual base class <abstract base class>` of the exception object,
238+
or a tuple containing an item that is the class or a non-virtual base class
239+
of the exception object.
239240

240241
If no except clause matches the exception, the search for an exception handler
241242
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