Skip to content

Commit

Permalink
pythongh-124872: Clarify expected PyContext_WatchCallback return beha…
Browse files Browse the repository at this point in the history
…vior
  • Loading branch information
rhansen committed Oct 14, 2024
1 parent c5789a9 commit 4c115ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions Doc/c-api/contextvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ Context object management functions:
Any pending exception is cleared before the callback is called and restored
after the callback returns.
If the callback returns with an exception set, it must return ``-1``; this
exception will be printed as an unraisable exception using
:c:func:`PyErr_FormatUnraisable`. Otherwise it should return ``0``.
If the callback raises an exception it must return ``-1``; the exception
will be printed as an unraisable exception using
:c:func:`PyErr_FormatUnraisable` and discarded. Otherwise it must return
``0``.
.. versionadded:: 3.14
Expand Down
5 changes: 3 additions & 2 deletions Include/cpython/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ typedef enum {
* Any pending exception is cleared before the callback is called and restored
* after the callback returns.
*
* if the callback returns with an exception set, it must return -1. Otherwise
* it should return 0
* If the callback raises an exception it must return -1; the exception will be
* printed as an unraisable exception using PyErr_FormatUnraisable and
* discarded. Otherwise it must return 0.
*/
typedef int (*PyContext_WatchCallback)(PyContextEvent, PyObject *);

Expand Down

0 comments on commit 4c115ab

Please sign in to comment.