FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-119333: PyContext watchers notify get interp from tstate by fried · Pull Request #124444 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .h  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 2 additions & 3 deletions Include/cpython/context.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ typedef enum {
} 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
Expand Down
8 changes: 4 additions & 4 deletions Python/context.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ context_event_name(PyContextEvent event) {
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;
Expand Down Expand Up @@ -192,7 +192,7 @@ _PyContext_Enter(PyThreadState *ts, PyObject *octx)
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;
}

Expand Down Expand Up @@ -226,7 +226,7 @@ _PyContext_Exit(PyThreadState *ts, PyObject *octx)
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++;

Expand Down

Back | FazBrowse Home | New Git URL