Skip to content

Commit 84c233e

Browse files
committed
gh-119333: Change PyContext_WatchCallback to take PyObject
The PyContext struct is not intended to be public, and users of the API don't need anything more specific than PyObject. Also see gh-78943.
1 parent 69a4063 commit 84c233e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Doc/c-api/contextvars.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Context object management functions:
127127
128128
.. versionadded:: 3.14
129129
130-
.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyContext* ctx)
130+
.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyObject* ctx)
131131
132132
Type of a context object watcher callback function.
133133
If *event* is ``Py_CONTEXT_EVENT_ENTER``, then the callback is invoked

Include/cpython/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef enum {
4141
* if the callback returns with an exception set, it must return -1. Otherwise
4242
* it should return 0
4343
*/
44-
typedef int (*PyContext_WatchCallback)(PyContextEvent, PyContext *);
44+
typedef int (*PyContext_WatchCallback)(PyContextEvent, PyObject *);
4545

4646
/*
4747
* Register a per-interpreter callback that will be invoked for context object

Python/context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static void notify_context_watchers(PyContextEvent event, PyContext *ctx, PyThre
124124
if (bits & 1) {
125125
PyContext_WatchCallback cb = interp->context_watchers[i];
126126
assert(cb != NULL);
127-
if (cb(event, ctx) < 0) {
127+
if (cb(event, (PyObject *)ctx) < 0) {
128128
PyErr_FormatUnraisable(
129129
"Exception ignored in %s watcher callback for %R",
130130
context_event_name(event), ctx);

0 commit comments

Comments
 (0)