8000 gh-124872: Clarify expected PyContext_WatchCallback return behavior · rhansen/cpython@4c115ab · GitHub
[go: up one dir, main page]

Skip to content

Commit 4c115ab

Browse files
committed
pythongh-124872: Clarify expected PyContext_WatchCallback return behavior
1 parent c5789a9 commit 4c115ab

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Doc/c-api/contextvars.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ Context object management functions:
144144
Any pending exception is cleared before the callback is called and restored
145145
after the callback returns.
146146
147-
If the callback returns with an exception set, it must return ``-1``; this
148-
exception will be printed as an unraisable exception using
149-
:c:func:`PyErr_FormatUnraisable`. Otherwise it should return ``0``.
147+
If the callback raises an exception it must return ``-1``; the exception
148+
will be printed as an unraisable exception using
149+
:c:func:`PyErr_FormatUnraisable` and discarded. Otherwise it must return
150+
``0``.
150151
151152
.. versionadded:: 3.14
152153

Include/cpython/context.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ typedef enum {
5252
* Any pending exception is cleared before the callback is called and restored
5353
* after the callback returns.
5454
*
55-
* if the callback returns with an exception set, it must return -1. Otherwise
56-
* it should return 0
55+
* If the callback raises an exception it must return -1; the exception will be
56+
* printed as an unraisable exception using PyErr_FormatUnraisable and
57+
* discarded. Otherwise it must return 0.
5758
*/
5859
typedef int (*PyContext_WatchCallback)(PyContextEvent, PyObject *);
5960

0 commit comments

Comments
 (0)
0