Skip to content

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

Merged
vstinner merged 8 commits into
python:masterfrom
vstinner:get_interp
Aug 3, 2018
Merged

bpo-34301: Add _PyInterpreterState_Get() helper function#8592
vstinner merged 8 commits into
python:masterfrom
vstinner:get_interp

Conversation

@vstinner

@vstinner vstinner commented Jul 31, 2018

Copy link
Copy Markdown
Member

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.
Comment thread Python/ceval.c Outdated
{
PyThreadState *tstate = PyThreadState_GET();
return tstate->interp->eval_frame(f, throwflag);
PyInterpreterState *interp = _PyInterpreterState_Get();

Copy link
Copy Markdown
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

vstinner commented Aug 1, 2018

Copy link
Copy Markdown
Member Author

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

vstinner commented Aug 1, 2018

Copy link
Copy Markdown
Member Author

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