bpo-38858: Add _Py_IsMainInterpreter(tstate) (GH-17293)

This commit is contained in:
Victor Stinner 2019-11-20 17:34:39 +01:00 committed by GitHub
parent db7925a1ca
commit fff7bbfdb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View file

@ -1466,9 +1466,9 @@ static PyObject *
_thread__is_main_interpreter_impl(PyObject *module)
/*[clinic end generated code: output=7dd82e1728339adc input=cc1eb00fd4598915]*/
{
_PyRuntimeState *runtime = &_PyRuntime;
PyInterpreterState *interp = _PyRuntimeState_GetThreadState(runtime)->interp;
return PyBool_FromLong(interp == runtime->interpreters.main);
PyThreadState *tstate = _PyThreadState_GET();
int is_main = _Py_IsMainInterpreter(tstate);
return PyBool_FromLong(is_main);
}
static PyMethodDef thread_methods[] = {