Skip to content

Commit 26de214

Browse files
authored
gh-124989: remove exception related details which have moved to cpython/InternalsDoc (#1428)
1 parent e8a0195 commit 26de214

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

internals/interpreter.rst

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,7 @@ Do not confuse the evaluation stack with the call stack, which is used to implem
171171
Error handling
172172
==============
173173

174-
When an instruction like ``BINARY_OP`` encounters an error, an exception is raised.
175-
At this point, a traceback entry is added to the exception (by ``PyTraceBack_Here()``) and cleanup is performed.
176-
In the simplest case (absent any ``try`` blocks), this results in the remaining objects being popped off the evaluation stack and their reference count decremented (if not ``NULL``) .
177-
Then the interpreter function (``_PyEval_EvalFrameDefault()``) returns ``NULL``.
178-
179-
However, if an exception is raised in a ``try`` block, the interpreter must jump to the corresponding ``except`` or ``finally`` block.
180-
In 3.10 and before, there was a separate "block stack" which was used to keep track of nesting ``try`` blocks.
181-
In 3.11, this mechanism has been replaced by a statically generated table, ``code->co_exceptiontable``,
182-
which is described in detail in the `internals documentation
174+
See the `internals documentation
183175
<https://github.com/python/cpython/blob/main/InternalDocs/exception_handling.md>`_.
184176

185177
The locations table
@@ -206,18 +198,6 @@ From C code, you have to call :c:func:`PyCode_Addr2Location`.
206198
Fortunately, the locations table is only consulted by exception handling (to set ``tb_lineno``) and by tracing (to pass the line number to the tracing function).
207199
In order to reduce the overhead during tracing, the mapping from instruction offset to line number is cached in the ``_co_linearray`` field.
208200

209-
Exception chaining
210-
------------------
211-
212-
When an exception is raised during exception handling, the new exception is chained to the old one.
213-
This is done by making the ``__context__`` field of the new exception point to the old one.
214-
This is the responsibility of ``_PyErr_SetObject()`` in :cpy-file:`Python/errors.c` (which is ultimately called by all ``PyErr_Set*()`` functions).
215-
Separately, if a statement of the form :samp:`raise {X} from {Y}` is executed, the ``__cause__`` field of the raised exception (:samp:`{X}`) is set to :samp:`{Y}`.
216-
This is done by :c:func:`PyException_SetCause`, called in response to all ``RAISE_VARARGS`` instructions.
217-
A special case is :samp:`raise {X} from None`, which sets the ``__cause__`` field to ``None`` (at the C level, it sets ``cause`` to ``NULL``).
218-
219-
(TODO: Other exception details.)
220-
221201
Python-to-Python calls
222202
======================
223203

0 commit comments

Comments
 (0)