Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-119786: move a few more details on exception handling from devguide to InternalDocs#124989

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
iritkatriel merged 1 commit intopython:mainfromiritkatriel:doc-exceptions
Oct 4, 2024
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-119786: move a few more details on exception handling from devguid…
…e to InternalDocs
  • Loading branch information
@iritkatriel
iritkatriel committedOct 4, 2024
commit90f5d70066a718fc23216d6913fe93d68b4d26e1
12 changes: 11 additions & 1 deletionInternalDocs/exception_handling.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -75,7 +75,8 @@ table. If it finds a handler, control flow transfers to it. Otherwise, the
exception bubbles up to the caller, and the caller's frame is
checked for a handler covering the `CALL` instruction. This
repeats until a handler is found or the topmost frame is reached.
If no handler is found, the program terminates. During unwinding,
If no handler is found, then the interpreter function
(``_PyEval_EvalFrameDefault()``) returns NULL. During unwinding,
the traceback is constructed as each frame is added to it by
``PyTraceBack_Here()``, which is in
[Python/traceback.c](https://github.com/python/cpython/blob/main/Python/traceback.c).
Expand DownExpand Up@@ -182,3 +183,12 @@ The interpreter's function to lookup the table by instruction offset is
The Python function ``_parse_exception_table()`` in
[Lib/dis.py](https://github.com/python/cpython/blob/main/Lib/dis.py)
returns the exception table content as a list of namedtuple instances.

Exception Chaining Implementation
---------------------------------

[Exception chaining](https://docs.python.org/dev/tutorial/errors.html#exception-chaining)
refers to setting the ``__context__`` and ``__cause__`` fields of an exception as it is
being raised. The ``__context__`` field is set by ``_PyErr_SetObject()`` in
:cpy-file:`Python/errors.c` (which is ultimately called by all ``PyErr_Set*()`` functions).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(cpy-file is a Sphinx role; but this is now merged so you can change it next time)

iritkatriel reacted with thumbs up emoji
Copy link
Member

@AA-TurnerAA-TurnerOct 4, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Oh oops, I missed that -- PR in a moment. [#124990]

A

The ``__cause__`` field (explicit chaining) is set by the ``RAISE_VARARGS`` bytecode.

[8]ページ先頭

©2009-2025 Movatter.jp