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

Skip to content

Commit 2d5e9f8

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

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
@@ -253,9 +253,10 @@ is found that matches the exception. An expression-less except clause, if
253253
present, must be last; it matches any exception. For an except clause with an
254254
expression, that expression is evaluated, and the clause matches the exception
255255
if the resulting object is "compatible" with the exception. An object is
256-
compatible with an exception if it is the class or a base class of the exception
257-
object, or a tuple containing an item that is the class or a base class of
258-
the exception object.
256+
compatible with an exception if the object is the class or a
257+
:term:`non-virtual base class <abstract base class>` of the exception object,
258+
or a tuple containing an item that is the class or a non-virtual base class
259+
of the exception object.
259260

260261
If no except clause matches the exception, the search for an exception handler
261262
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
@@ -249,8 +249,9 @@ a stack traceback, except when the exception is :exc:`SystemExit`.
249249

250250
Exceptions are identified by class instances. The :keyword:`except` clause is
251251
selected depending on the class of the instance: it must reference the class of
252-
the instance or a base class thereof. The instance can be received by the
253-
handler and can carry additional information about the exceptional condition.
252+
the instance or a :term:`non-virtual base class <abstract base class>` thereof.
253+
The instance can be received by the handler and can carry additional information
254+
about the exceptional condition.
254255

255256
.. note::
256257

0 commit comments

Comments
 (0)
0