]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43268: _Py_IsMainInterpreter() now expects interp (GH-24577)
authorVictor Stinner <vstinner@python.org>
Fri, 19 Feb 2021 12:33:31 +0000 (13:33 +0100)
committerGitHub <noreply@github.com>
Fri, 19 Feb 2021 12:33:31 +0000 (13:33 +0100)
The _Py_IsMainInterpreter() function now expects interp rather than
tstate.

Include/internal/pycore_pystate.h
Objects/longobject.c
Objects/typeobject.c
Objects/unicodeobject.c
Python/ceval.c
Python/context.c
Python/import.c
Python/pylifecycle.c
Python/pystate.c

index 0cd5550cfda5c407e73a92792667aa345ed90a28..4b894f3eff49672126ad51688858c18371cf2aa5 100644 (file)
@@ -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);
 }
 
 
index 240e92a41e0ec093a6c7105984131041b75213e3..c0b4ce079e46aa344c4b5d7d1c6d9ebd886172d0 100644 (file)
@@ -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) {
index 3498f0d484e01e2b31b234d8dc0f12ba428308a1..9dbb7bed50b3f9cd04be1a8afb05939358629190 100644 (file)
@@ -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();
     }
 }
index 64fd408085d5e567eba4bb48ff917675a01c7814..498f3933dec6a3cc5f0aaf90596ecadd9b578de5 100644 (file)
@@ -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,
index 0b7400359e001b88cac45bc2c370155705555613..81a21c9a0f53431512d97915d4b9db70aea2ae83 100644 (file)
@@ -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. */
index 82826bf928fa05107dfbb35e119c2eccda439b2a..6a4562149cbec0b62178dfdb715c029de6f572f7 100644 (file)
@@ -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);
index 75ac21df82da94db5f018ec1f89728fafe9d6217..6189dcfbe0eca0aba13eaa2230c4431ed737417b 100644 (file)
@@ -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,
index bf5dcdd107e20faa077e54b745ff8ed3568b6247..f990fa6f1db3e721f7a980f870b3721bbe390928 100644 (file)
@@ -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);
     }
index 922e5bee2cbfcacda0240eb8fd0427167fcfef27..f4fd03982181b8c1961251e29fb0e341fb2053d0 100644 (file)
@@ -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();