-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
gh-141518: Add PyUnstable_InterpreterState_SetEvalFrameFunc() #141665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0e322e4
757eada
4ceff72
0a8d7cd
f694542
3e48d91
c167f44
c624f74
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Add a PyUnstable API for :pep:`523`: | ||
|
|
||
| * :c:type:`PyUnstable_FrameEvalFunction` type | ||
| * :c:func:`PyUnstable_InterpreterState_GetEvalFrameFunc` | ||
| * :c:func:`PyUnstable_InterpreterState_SetEvalFrameFunc` | ||
|
|
||
| Patch by Victor Stinner. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2595,6 +2595,29 @@ create_managed_weakref_nogc_type(PyObject *self, PyObject *Py_UNUSED(args)) | |
| } | ||
|
|
||
|
|
||
| static PyObject * | ||
| noop_eval(PyThreadState *tstate, struct _PyInterpreterFrame *f, int exc) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To implement an eval function, you should likely use the internal C API ( I don't think that it's worth it to expose
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These functions are rather useless without making
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The API changed in Python 3.11 to take a I wouldn't say that this API is useless without a public API for
It would make the code (way) slower,
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What is the use, then?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @emmatyping @efimov-mikhail: Do you have an opinion on these questions?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, the main idea of this change is not really to make those functions public. We mark them as I agree that it's not the perfect position for us, but current situation isn't any better. |
||
| { | ||
| return NULL; | ||
| } | ||
|
|
||
| static PyObject * | ||
| test_interpreter_setevalframefunc(PyObject *self, PyObject *Py_UNUSED(args)) | ||
| { | ||
| PyInterpreterState *interp = PyInterpreterState_Get(); | ||
| PyUnstable_FrameEvalFunction eval_func; | ||
|
|
||
| eval_func = PyUnstable_InterpreterState_GetEvalFrameFunc(interp); | ||
|
|
||
| PyUnstable_InterpreterState_SetEvalFrameFunc(interp, noop_eval); | ||
| assert(PyUnstable_InterpreterState_GetEvalFrameFunc(interp) == noop_eval); | ||
|
|
||
| PyUnstable_InterpreterState_SetEvalFrameFunc(interp, eval_func); | ||
|
|
||
| Py_RETURN_NONE; | ||
| } | ||
|
|
||
|
|
||
| static PyMethodDef TestMethods[] = { | ||
| {"set_errno", set_errno, METH_VARARGS}, | ||
| {"test_config", test_config, METH_NOARGS}, | ||
|
|
@@ -2691,6 +2714,8 @@ static PyMethodDef TestMethods[] = { | |
| {"toggle_reftrace_printer", toggle_reftrace_printer, METH_O}, | ||
| {"create_managed_weakref_nogc_type", | ||
| create_managed_weakref_nogc_type, METH_NOARGS}, | ||
| {"test_interpreter_setevalframefunc", | ||
efimov-mikhail marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| test_interpreter_setevalframefunc, METH_NOARGS}, | ||
| {NULL, NULL} /* sentinel */ | ||
| }; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.