-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
Conversation
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(); |
There was a problem hiding this comment.
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?
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? |
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. |
_PyInterpreterState_Get() now fails with a fatal error if tstate->interp is NULL.
sys_setcheckinterval() now uses a local variable to parse arguments,
before writing into interp->check_interval.
https://bugs.python.org/issue34301