| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
This enables developers to associate state with the callback without relying on globals. Also, refactor the tests for improved readability and extensibility, and to cover the new state object.
| PyType_WatchCallback type_watchers[TYPE_MAX_WATCHERS]; | ||
| PyCode_WatchCallback code_watchers[CODE_MAX_WATCHERS]; | ||
| PyContext_WatchCallback context_watchers[CONTEXT_MAX_WATCHERS]; | ||
| PyObject *context_watchers[CONTEXT_MAX_WATCHERS]; |
There was a problem hiding this comment.
Does this need a Py_VISIT somewhere? I didn't see any for the other fields in this struct, but maybe the GC does something special with this struct?
Sorry, something went wrong.
| Registers the callable object *callback* as a context object watcher for the | ||
| current interpreter. When a context event occurs, *callback* is called with | ||
| two arguments: | ||
|
|
||
| #. An event type ID from :c:type:`PyContextEvent`. | ||
| #. An object containing event-specific supplemental data; see | ||
| :c:type:`PyContextEvent` for details. |
There was a problem hiding this comment.
I think my preference would be to create a new contextvars.ContextSwitchedEvent class that holds the Context object and pass that instead, but this is a smaller change.
Sorry, something went wrong.
|
I think that I would prefer to add a void *data (or void *ctx) parameter to the callback API, rather than moving to PyObject *callback. |
Sorry, something went wrong.
I'm a tad concerned about void *data. See my comment here: #127124 (comment). That said, I'm not totally opposed to it, but we should definitely explore options before introducing this (and precedent for future void *) into the C API. Do you think this is worth bringing up on https://github.com/capi-workgroup/decisions? |
Sorry, something went wrong.
I would prefer void* instead of PyObject*. But I never used this API and I didn't design it. So I'm not sure that I'm the right person to make a decision here. |
Sorry, something went wrong.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This enables developers to associate state with the callback without relying on globals.
Also, refactor the tests for improved readability and extensibility, and to cover the new state object.
This PR is an alternative to #127140.
This PR also incorporates #124741 because I don't think it makes sense to call a callable object without backing up the exception state first.
📚 Documentation preview 📚: https://cpython-previews--127247.org.readthedocs.build/