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-34301: Add _PyInterpreterState_Get() helper function #8592

Merged
merged 8 commits into from
Aug 3, 2018
Merged

bpo-34301: Add _PyInterpreterState_Get() helper function #8592

merged 8 commits into from
Aug 3, 2018

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jul 31, 2018

sys_setcheckinterval() now uses a local variable to parse arguments,
before writing into interp->check_interval.

https://bugs.python.org/issue34301

sys_setcheckinterval() now uses a local variable to parse arguments,
before writing into interp->check_interval.
Python/ceval.c Outdated
@@ -532,8 +532,8 @@ PyEval_EvalFrame(PyFrameObject *f) {
PyObject *
PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
{
PyThreadState *tstate = PyThreadState_GET();
return tstate->interp->eval_frame(f, throwflag);
PyInterpreterState *interp = _PyInterpreterState_Get();
Copy link
Member Author

Choose a reason for hiding this comment

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

Hum, PyThreadState_GET() doesn't check if the result is NULL, whereas _PyInterpreterState_Get() does. Do we need a _PyInterpreterState_GetUnchecked() for performance critical code?

@vstinner
Copy link
Member Author

vstinner commented Aug 1, 2018

I tried to declare _PyInterpreterState_Get() only if Py_BUILD_CORE is defined, but I also want to use it in Programs/_testembed.c which isn't compiled with Py_BUILD_CORE. So I only excluded the function from the stable ABI. But maybe we can even add the function to the regular API?

@vstinner
Copy link
Member Author

vstinner commented Aug 1, 2018

On Windows, the C compiler emits a warning in _PyInterpreter_Get() because the compiler doesn't understand that Py_FatalError() never returns. I proposed the PR #8606 to fix this issue.

@vstinner vstinner merged commit caba55b into python:master Aug 3, 2018
@vstinner vstinner deleted the get_interp branch September 19, 2018 22:52
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.

3 participants