Skip to content
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

bpo-38500: Add _PyInterpreterState_SetEvalFrameFunc() #17340

Merged
merged 1 commit into from
Mar 12, 2020
Merged

bpo-38500: Add _PyInterpreterState_SetEvalFrameFunc() #17340

merged 1 commit into from
Mar 12, 2020

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Nov 22, 2019

PyInterpreterState.eval_frame function now requires a tstate (Python
thread state) parameter.

Add private functions to the C API to get and set the frame
evaluation function:

  • Add tstate parameter to _PyFrameEvalFunction function type.
  • Add _PyInterpreterState_GetEvalFrameFunc() and
    _PyInterpreterState_SetEvalFrameFunc() functions.
  • Add tstate parameter to _PyEval_EvalFrameDefault().

https://bugs.python.org/issue38500

@brettcannon
Copy link
Member

I'm holding off on looking at this until the tstate question is resolved.

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself LGTM. However, I'm still not convinced that this is functionality we want to expose through the public API. So that question should be resolved before merging this. :)

(@brettcannon The question of passing tstate to the eval function seems unrelated.)

@ericsnowcurrently
Copy link
Member

Also, it would probably make sense to have an explicit mention of this in whatsnew doc (porting section?).

@brettcannon
Copy link
Member

@ericsnowcurrently I think the tstate discussion is related because @vstinner discussed changing the definition of PyFrameEvalFunction which is being explicitly dealt with here.

@brettcannon brettcannon removed their request for review January 22, 2020 23:46
@vstinner vstinner removed the needs backport to 3.8 only security fixes label Mar 10, 2020
@vstinner
Copy link
Member Author

Python 3.8.0 is now released. The internal C API can be used to access interp->eval_frame. I no longer want to backport this change to Python 3.8.

@vstinner
Copy link
Member Author

vstinner commented Mar 10, 2020

I rebased my PR on master. I merged PR #17187 ("bpo-38818: PyInterpreterState.eval_frame now pass tstate #17187") changes into this PR.

@vstinner
Copy link
Member Author

I plan to merge my PR 17340 at the end of week to not miss Python 3.9 feature freeze deadline, unless someone speaks up and find a good reason to not merge this PR. The PR adds a public C API PyInterpreterState_SetEvalFrameFunc() and now pass tstate to the frame evaluation function.

Please go to https://bugs.python.org/issue38500 for discussion, don't discuss the topic here.

@vstinner
Copy link
Member Author

@DinoV @ericsnowcurrently @brettcannon: Would you mind to review the update PR?

@vstinner
Copy link
Member Author

The Windows ARM job of Azure Pipelines PR failed on downloading dependencies ("urllib.error.HTTPError: HTTP Error 401: UNAUTHORIZED"). I will wait for reviews before restarting the job. Right now, I don't need a green CI, I don't plan to merge this PR before the end of the week.

@vstinner
Copy link
Member Author

@rsumner868: Hi, I saw you approving a few PRs. Would you mind to elaborate what you reviewed and explain why/how you approve a PR? This PR is controversial, you cannot simply approve it with no message.

@brettcannon brettcannon self-requested a review March 10, 2020 19:57
@markshannon
Copy link
Member

As I've reiterated in https://bugs.python.org/issue38500, I am strongly opposed to this being merged.

@vstinner vstinner changed the title bpo-38500: Add PyInterpreterState_SetEvalFrameFunc() bpo-38500: Add _PyInterpreterState_SetEvalFrameFunc() Mar 12, 2020
PyInterpreterState.eval_frame function now requires a tstate (Python
thread state) parameter.

Add private functions to the C API to get and set the frame
evaluation function:

* Add tstate parameter to _PyFrameEvalFunction function type.
* Add _PyInterpreterState_GetEvalFrameFunc() and
  _PyInterpreterState_SetEvalFrameFunc() functions.
* Add tstate parameter to _PyEval_EvalFrameDefault().
@vstinner
Copy link
Member Author

I took @markshannon's concerns in account and I updated my PR to only add private functions to the C API, not public functions.

@vstinner vstinner merged commit 0b72b23 into python:master Mar 12, 2020
@vstinner vstinner deleted the set_eval_frame branch March 12, 2020 22:18
@markshannon
Copy link
Member

@vstinner Thank you for making these functions private.

However, if they are documented in the Doc/c-api/init.rst, then they aren't that private.
Could you remove the documentation?
These functions have the potential to hurt performance by a significant amount, so hiding them (or warning that might well be removed in 3.10) would be good.

@vstinner
Copy link
Member Author

However, if they are documented in the Doc/c-api/init.rst, then they aren't that private. Could you remove the documentation?

I prefer to document them. The feature is part of the PEP 523 and we already had this discussion :-)

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

Successfully merging this pull request may close these issues.

6 participants