Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Include/internal/pycore_pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ _Py_IsMainThread(void)


static inline int
_Py_IsMainInterpreter(PyThreadState* tstate)
_Py_IsMainInterpreter(PyInterpreterState *interp)
{
/* Use directly _PyRuntime rather than tstate->interp->runtime, since
this function is used in performance critical code path (ceval) */
return (tstate->interp == _PyRuntime.interpreters.main);
return (interp == _PyRuntime.interpreters.main);
}


Expand Down
2 changes: 1 addition & 1 deletion Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5719,7 +5719,7 @@ _PyLong_Init(PyThreadState *tstate)
tstate->interp->small_ints[i] = v;
}

if (_Py_IsMainInterpreter(tstate)) {
if (_Py_IsMainInterpreter(tstate->interp)) {
/* initialize int_info */
if (Int_InfoType.tp_name == NULL) {
if (PyStructSequence_InitType2(&Int_InfoType, &int_info_desc) < 0) {
Expand Down
2 changes: 1 addition & 1 deletion Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void
_PyType_Fini(PyThreadState *tstate)
{
_PyType_ClearCache(&tstate->interp->type_cache);
if (_Py_IsMainInterpreter(tstate)) {
if (_Py_IsMainInterpreter(tstate->interp)) {
clear_slotdefs();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -15701,7 +15701,7 @@ _PyUnicode_Init(PyThreadState *tstate)
return _PyStatus_NO_MEMORY();
}

if (_Py_IsMainInterpreter(tstate)) {
if (_Py_IsMainInterpreter(tstate->interp)) {
/* initialize the linebreak bloom filter */
bloom_linebreak = make_bloom_mask(
PyUnicode_2BYTE_KIND, linebreak,
Expand Down
4 changes: 2 additions & 2 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ PyStatus
_PyEval_InitGIL(PyThreadState *tstate)
{
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (!_Py_IsMainInterpreter(tstate)) {
if (!_Py_IsMainInterpreter(tstate->interp)) {
/* Currently, the GIL is shared by all interpreters,
and only the main interpreter is responsible to create
and destroy it. */
Expand Down Expand Up @@ -326,7 +326,7 @@ void
_PyEval_FiniGIL(PyThreadState *tstate)
{
#ifndef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
if (!_Py_IsMainInterpreter(tstate)) {
if (!_Py_IsMainInterpreter(tstate->interp)) {
/* Currently, the GIL is shared by all interpreters,
and only the main interpreter is responsible to create
and destroy it. */
Expand Down
2 changes: 1 addition & 1 deletion Python/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ _PyContext_ClearFreeList(PyThreadState *tstate)
void
_PyContext_Fini(PyThreadState *tstate)
{
if (_Py_IsMainInterpreter(tstate)) {
if (_Py_IsMainInterpreter(tstate->interp)) {
Py_CLEAR(_token_missing);
}
_PyContext_ClearFreeList(tstate);
Expand Down
2 changes: 1 addition & 1 deletion Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ _PyImport_FixupExtensionObject(PyObject *mod, PyObject *name,
return -1;
}

if (_Py_IsMainInterpreter(tstate)) {
if (_Py_IsMainInterpreter(tstate->interp)) {
if (def->m_size == -1) {
if (def->m_base.m_copy) {
/* Somebody already imported the module,
Expand Down
10 changes: 5 additions & 5 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ interpreter_update_config(PyThreadState *tstate, int only_update_path_config)
}
}

if (_Py_IsMainInterpreter(tstate)) {
if (_Py_IsMainInterpreter(tstate->interp)) {
PyStatus status = _PyConfig_WritePathConfig(config);
if (_PyStatus_EXCEPTION(status)) {
_PyErr_SetFromPyStatus(status);
Expand Down Expand Up @@ -627,7 +627,7 @@ static PyStatus
pycore_init_types(PyThreadState *tstate)
{
PyStatus status;
int is_main_interp = _Py_IsMainInterpreter(tstate);
int is_main_interp = _Py_IsMainInterpreter(tstate->interp);

status = _PyGC_Init(tstate);
if (_PyStatus_EXCEPTION(status)) {
Expand Down Expand Up @@ -1003,7 +1003,7 @@ init_interp_main(PyThreadState *tstate)
assert(!_PyErr_Occurred(tstate));

PyStatus status;
int is_main_interp = _Py_IsMainInterpreter(tstate);
int is_main_interp = _Py_IsMainInterpreter(tstate->interp);
PyInterpreterState *interp = tstate->interp;
const PyConfig *config = _PyInterpreterState_GetConfig(interp);

Expand Down Expand Up @@ -1597,7 +1597,7 @@ finalize_interp_types(PyThreadState *tstate)
static void
finalize_interp_clear(PyThreadState *tstate)
{
int is_main_interp = _Py_IsMainInterpreter(tstate);
int is_main_interp = _Py_IsMainInterpreter(tstate->interp);

/* Clear interpreter state and all thread states */
_PyInterpreterState_Clear(tstate);
Expand All @@ -1622,7 +1622,7 @@ finalize_interp_clear(PyThreadState *tstate)
static void
finalize_interp_delete(PyThreadState *tstate)
{
if (_Py_IsMainInterpreter(tstate)) {
if (_Py_IsMainInterpreter(tstate->interp)) {
/* Cleanup auto-thread-state */
_PyGILState_Fini(tstate);
}
Expand Down
2 changes: 1 addition & 1 deletion Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ PyThreadState_IsCurrent(PyThreadState *tstate)
PyStatus
_PyGILState_Init(PyThreadState *tstate)
{
if (!_Py_IsMainInterpreter(tstate)) {
if (!_Py_IsMainInterpreter(tstate->interp)) {
/* Currently, PyGILState is shared by all interpreters. The main
* interpreter is responsible to initialize it. */
return _PyStatus_OK();
Expand Down