} PyContextEvent;
/*
- * A Callback to clue in non-python contexts impls about a
- * change in the active python context.
+ * Callback to be invoked when a context object is entered or exited.
*
- * The callback is invoked with the event and a reference to =
+ * The callback is invoked with the event and a reference to
* the context after its entered and before its exited.
*
* if the callback returns with an exception set, it must return -1. Otherwise
Py_UNREACHABLE();
}
-static void notify_context_watchers(PyContextEvent event, PyContext *ctx)
+static void notify_context_watchers(PyContextEvent event, PyContext *ctx, PyThreadState *ts)
{
assert(Py_REFCNT(ctx) > 0);
- PyInterpreterState *interp = _PyInterpreterState_GET();
+ PyInterpreterState *interp = ts->interp;
assert(interp->_initialized);
uint8_t bits = interp->active_context_watchers;
int i = 0;
ts->context = Py_NewRef(ctx);
ts->context_ver++;
- notify_context_watchers(Py_CONTEXT_EVENT_ENTER, ctx);
+ notify_context_watchers(Py_CONTEXT_EVENT_ENTER, ctx, ts);
return 0;
}
return -1;
}
- notify_context_watchers(Py_CONTEXT_EVENT_EXIT, ctx);
+ notify_context_watchers(Py_CONTEXT_EVENT_EXIT, ctx, ts);
Py_SETREF(ts->context, (PyObject *)ctx->ctx_prev);
ts->context_ver++;