summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-02-19 12:33:31 (GMT)
committerGitHub <noreply@github.com>2021-02-19 12:33:31 (GMT)
commit101bf69ff18a946fed7c274f088878aaf85174cc (patch)
tree40aad6b5b086f5eae0135cd9f695365af3be5a2a
parent62078101ea1be5d2fc472a3f0d9d135e0bd5cd38 (diff)
downloadcpython-101bf69ff18a946fed7c274f088878aaf85174cc.zip
cpython-101bf69ff18a946fed7c274f088878aaf85174cc.tar.gz
cpython-101bf69ff18a946fed7c274f088878aaf85174cc.tar.bz2
bpo-43268: _Py_IsMainInterpreter() now expects interp (GH-24577)
The _Py_IsMainInterpreter() function now expects interp rather than tstate.
-rw-r--r--Include/internal/pycore_pystate.h4
-rw-r--r--Objects/longobject.c2
-rw-r--r--Objects/typeobject.c2
-rw-r--r--Objects/unicodeobject.c2
-rw-r--r--Python/ceval.c4
-rw-r--r--Python/context.c2
-rw-r--r--Python/import.c2
-rw-r--r--Python/pylifecycle.c10
-rw-r--r--Python/pystate.c2
9 files changed, 15 insertions, 15 deletions
diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h
index 0cd5550..4b894f3 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -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);
}
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 240e92a..c0b4ce0 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -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) {
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 3498f0d..9dbb7be 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -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();
}
}
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 64fd408..498f393 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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,
diff --git a/Python/ceval.c b/Python/ceval.c
index 0b74003..81a21c9 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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. */
@@ -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. */
diff --git a/Python/context.c b/Python/context.c
index 82826bf..6a45621 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -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);
diff --git a/Python/import.c b/Python/import.c
index 75ac21d..6189dcf 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -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,
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index bf5dcdd..f990fa6 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -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);
@@ -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)) {
@@ -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);
@@ -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);
@@ -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);
}
diff --git a/Python/pystate.c b/Python/pystate.c
index 922e5be..f4fd039 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -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();