Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
0e322e4757eada4ceff720a8d7cdf6945423e48d91c167f44c624f748fd495bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1091,6 +1091,14 @@ New features | ||
| * Add :c:func:`PyTuple_FromArray` to create a :class:`tuple` from an array. | ||
| (Contributed by Victor Stinner in :gh:`111489`.) | ||
| * Add a PyUnstable API for :pep:`523`: | ||
| * :c:type:`PyUnstable_FrameEvalFunction` type | ||
| * :c:func:`PyUnstable_InterpreterState_GetEvalFrameFunc` | ||
| * :c:func:`PyUnstable_InterpreterState_SetEvalFrameFunc` | ||
| (Contributed by Victor Stinner in :gh:`141518`.) | ||
| * Add :c:func:`PyUnstable_Object_Dump` to dump an object to ``stderr``. | ||
| It should only be used for debugging. | ||
| (Contributed by Victor Stinner in :gh:`141070`.) | ||
| @@ -1227,6 +1235,13 @@ Deprecated C APIs | ||
| since 3.15 and will be removed in 3.20. | ||
| (Contributed by Sergey B Kirpichev in :gh:`141004`.) | ||
| * :c:func:`!_PyInterpreterState_GetEvalFrameFunc` and | ||
| :c:func:`!_PyInterpreterState_SetEvalFrameFunc` functions are deprecated | ||
| and will be removed in Python 3.20. Use | ||
| :c:func:`PyUnstable_InterpreterState_GetEvalFrameFunc` and | ||
| :c:func:`PyUnstable_InterpreterState_SetEvalFrameFunc` instead. | ||
| (Contributed by Victor Stinner in :gh:`141518`.) | ||
efimov-mikhail marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| .. Add C API deprecations above alphabetically, not here at the end. | ||
| 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,32 @@ 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 MemberAuthor 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 MemberAuthor 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? MemberAuthor 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?
| ||
| { | ||
| return NULL; | ||
| } | ||
| static PyObject * | ||
| test_interpreter_setevalframefunc(PyObject *self, PyObject *Py_UNUSED(args)) | ||
| { | ||
| PyInterpreterState *interp = PyInterpreterState_Get(); | ||
| PyUnstable_FrameEvalFunction eval_func; | ||
| int res; | ||
| eval_func = PyUnstable_InterpreterState_GetEvalFrameFunc(interp); | ||
| res = PyUnstable_InterpreterState_SetEvalFrameFunc(interp, noop_eval); | ||
| assert(res == 0); | ||
| assert(PyUnstable_InterpreterState_GetEvalFrameFunc(interp) == noop_eval); | ||
| res = PyUnstable_InterpreterState_SetEvalFrameFunc(interp, eval_func); | ||
| assert(res == 0); | ||
| Py_RETURN_NONE; | ||
| } | ||
| static PyMethodDef TestMethods[] = { | ||
| {"set_errno", set_errno, METH_VARARGS}, | ||
| {"test_config", test_config, METH_NOARGS}, | ||
| @@ -2691,6 +2717,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.
Uh oh!There was an error while loading. Please reload this page. | ||
| test_interpreter_setevalframefunc, METH_NOARGS}, | ||
| {NULL, NULL} /* sentinel */ | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.