@@ -122,18 +122,24 @@ Context object management functions:
122122.. c:type:: PyContextEvent
123123
124124 Enumeration of possible context object watcher events:
125- - ``Py_CONTEXT_EVENT_ENTER``
126- - ``Py_CONTEXT_EVENT_EXIT``
125+
126+ - ``Py_CONTEXT_EVENT_ENTER``: A context has been entered, causing the
127+ :term:`current context` to switch to it. The object passed to the watch
128+ callback is the now-current :class:`contextvars.Context` object. Each
129+ enter event will eventually have a corresponding exit event for the same
130+ context object after any subsequently entered contexts have themselves been
131+ exited.
132+ - ``Py_CONTEXT_EVENT_EXIT``: A context is about to be exited, which will
133+ cause the :term:`current context` to switch back to what it was before the
134+ context was entered. The object passed to the watch callback is the
135+ still-current :class:`contextvars.Context` object.
127136
128137 .. versionadded:: 3.14
129138
130139.. c:type:: int (*PyContext_WatchCallback)(PyContextEvent event, PyContext * ctx)
131140
132- Type of a context object watcher callback function.
133- If *event* is ``Py_CONTEXT_EVENT_ENTER``, then the callback is invoked
134- after *ctx* has been set as the current context for the current thread.
135- Otherwise, the callback is invoked before the deactivation of *ctx* as the current context
136- and the restoration of the previous contex object for the current thread.
141+ Context object watcher callback function. The object passed to the callback
142+ is event-specific; see :c:type:`PyContextEvent` for details.
137143
138144 If the callback returns with an exception set, it must return ``-1 ``; this
139145 exception will be printed as an unraisable exception using
0 commit comments