Skip to content

bpo-46850: Move _PyInterpreterState_SetEvalFrameFunc() to internal C API #32054

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

Merged
merged 1 commit into from
Apr 1, 2022
Merged

bpo-46850: Move _PyInterpreterState_SetEvalFrameFunc() to internal C API #32054

merged 1 commit into from
Apr 1, 2022

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Mar 22, 2022

Move the private _PyFrameEvalFunction type, and private
_PyInterpreterState_GetEvalFrameFunc() and
_PyInterpreterState_SetEvalFrameFunc() functions to the internal C
API. The _PyFrameEvalFunction callback function type now uses the
_PyInterpreterFrame type which is part of the internal C API.

Update the _PyFrameEvalFunction documentation.

https://bugs.python.org/issue46850

@vstinner
Copy link
Member Author

See also PR #32052 "Remove _PyEval_EvalFrameDefault() function".

@vstinner
Copy link
Member Author

According to a code search on top 5000 PyPI project (2022-01-26), two debugger projects are affected, the same projects than the projects affected by PR #32052.

debugpy-1.5.1.zip:

src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.pxd: # ctypedef PyObject* _PyFrameEvalFunction(PyThreadState* tstate, PyFrameObject *frame, int exc)
src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.pxd: # ctypedef PyObject* _PyFrameEvalFunction(PyFrameObject *frame, int exc)
src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.pxd: ctypedef PyObject* _PyFrameEvalFunction(...)
src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.pxd: _PyFrameEvalFunction eval_frame
src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.template.pyx: state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_39
src/debugpy/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.template.pyx: state.interp.eval_frame = <_PyFrameEvalFunction *> get_bytecode_while_frame_eval_38

ptvsd-4.3.2.zip:

src/ptvsd/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.pxd: ctypedef PyObject* _PyFrameEvalFunction(PyFrameObject *frame, int exc)
src/ptvsd/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.pxd: _PyFrameEvalFunction eval_frame

@jansel
Copy link

jansel commented Mar 28, 2022

This (and PEP-523) is used in TorchDynamo:
https://github.com/facebookresearch/torchdynamo

We (the PyTorch team) are planning to include TorchDynamo as part of PyTorch 2.0.

@vstinner
Copy link
Member Author

vstinner commented Apr 1, 2022

PR rebased on top of #32052 that I plan to merge first.

@vstinner vstinner changed the title bpo-46850: Remove _PyInterpreterState_SetEvalFrameFunc() bpo-46850: Move _PyInterpreterState_SetEvalFrameFunc() to internal C API Apr 1, 2022
Move the private _PyFrameEvalFunction type, and private
_PyInterpreterState_GetEvalFrameFunc() and
_PyInterpreterState_SetEvalFrameFunc() functions to the internal C
API. The _PyFrameEvalFunction callback function type now uses the
_PyInterpreterFrame type which is part of the internal C API.

Update the _PyFrameEvalFunction documentation.
@vstinner vstinner merged commit f877b40 into python:main Apr 1, 2022
@vstinner vstinner deleted the eval_func branch April 1, 2022 08:55
vstinner added a commit that referenced this pull request Apr 6, 2022
…H-32052)" (GH-32343)

* Revert "bpo-46850: Move _PyInterpreterState_SetEvalFrameFunc() to internal C API (GH-32054)"

This reverts commit f877b40.

* Revert "bpo-46850: Move _PyEval_EvalFrameDefault() to internal C API (GH-32052)"

This reverts commit b9a5522.
@itamarst
Copy link

I rely on this API and (other PEP 523 APIs as well) for https://pythonspeed.com/sciagraph/, so would like it or some equivalent to continue to exist.

@vstinner
Copy link
Member Author

This change was reverted: #32343

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants