https://github.com/python/cpython/commit/b69da006a4f493f1eec0df413f81fbfc3e366783
commit: b69da006a4f493f1eec0df413f81fbfc3e366783
branch: main
author: Victor Stinner <vstin...@python.org>
committer: vstinner <vstin...@python.org>
date: 2025-03-20T11:35:23Z
summary:

gh-131238: Remove includes from pycore_interp.h (#131495)

Remove also now unused includes in C files.

files:
M Include/internal/pycore_code.h
M Include/internal/pycore_freelist.h
M Include/internal/pycore_interp.h
M Modules/_interpretersmodule.c
M Modules/_lsprof.c
M Modules/_testcapi/watchers.c
M Modules/_testinternalcapi.c
M Modules/signalmodule.c
M Objects/abstract.c
M Objects/codeobject.c
M Objects/iterobject.c
M Objects/object.c
M Objects/tupleobject.c
M Parser/myreadline.c
M Python/_warnings.c
M Python/ceval.c
M Python/ceval_gil.c
M Python/crossinterp.c
M Python/gc.c
M Python/gc_free_threading.c
M Python/instrumentation.c
M Python/legacy_tracing.c
M Python/perf_trampoline.c
M Python/pylifecycle.c
M Python/pystate.c
M Python/sysmodule.c
M Python/traceback.c

diff --git a/Include/internal/pycore_code.h b/Include/internal/pycore_code.h
index e6c388080ea79c..2839b9b7ebe0fb 100644
--- a/Include/internal/pycore_code.h
+++ b/Include/internal/pycore_code.h
@@ -8,9 +8,8 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-#include "pycore_structs.h"     // _Py_CODEUNIT
-#include "pycore_stackref.h"    // _PyStackRef
 #include "pycore_backoff.h"     // _Py_BackoffCounter
+#include "pycore_structs.h"     // _Py_CODEUNIT
 #include "pycore_tstate.h"      // _PyThreadStateImpl
 
 
diff --git a/Include/internal/pycore_freelist.h 
b/Include/internal/pycore_freelist.h
index 9c5a48835fabdf..f3c9a669ad3512 100644
--- a/Include/internal/pycore_freelist.h
+++ b/Include/internal/pycore_freelist.h
@@ -9,7 +9,8 @@ extern "C" {
 #endif
 
 #include "pycore_freelist_state.h"      // struct _Py_freelists
-#include "pycore_object.h"              // _PyObject_IS_GC
+#include "pycore_interp_structs.h"      // PyInterpreterState
+#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_STORE_PTR_RELAXED()
 #include "pycore_pystate.h"             // _PyThreadState_GET
 #include "pycore_stats.h"               // OBJECT_STAT_INC
 
diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 49eedd8d2a2332..5b1bb202191b51 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -8,7 +8,7 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-#include "pycore_genobject.h"     // _PyGen_FetchStopIterationValue
+#include "pycore_interp_structs.h" // PyInterpreterState
 
 
 /* interpreter state */
@@ -27,7 +27,6 @@ extern "C" {
 
 extern void _PyInterpreterState_Clear(PyThreadState *tstate);
 
-
 static inline PyThreadState*
 _PyInterpreterState_GetFinalizing(PyInterpreterState *interp) {
     return (PyThreadState*)_Py_atomic_load_ptr_relaxed(&interp->_finalizing);
@@ -53,7 +52,6 @@ _PyInterpreterState_SetFinalizing(PyInterpreterState *interp, 
PyThreadState *tst
 }
 
 
-
 // Exports for the _testinternalcapi module.
 PyAPI_FUNC(int64_t) _PyInterpreterState_ObjectToID(PyObject *);
 PyAPI_FUNC(PyInterpreterState *) _PyInterpreterState_LookUpID(int64_t);
diff --git a/Modules/_interpretersmodule.c b/Modules/_interpretersmodule.c
index d4d90b5f31b7ab..707e654005bc59 100644
--- a/Modules/_interpretersmodule.c
+++ b/Modules/_interpretersmodule.c
@@ -6,16 +6,14 @@
 #endif
 
 #include "Python.h"
-#include "pycore_abstract.h"      // _PyIndex_Check()
+#include "pycore_code.h"          // _PyCode_HAS_EXECUTORS()
 #include "pycore_crossinterp.h"   // _PyXIData_t
 #include "pycore_interp.h"        // _PyInterpreterState_IDIncref()
-#include "pycore_initconfig.h"    // _PyErr_SetFromPyStatus()
 #include "pycore_modsupport.h"    // _PyArg_BadArgument()
 #include "pycore_namespace.h"     // _PyNamespace_New()
 #include "pycore_pybuffer.h"      // _PyBuffer_ReleaseInInterpreterAndRawFree()
-#include "pycore_pyerrors.h"      // _Py_excinfo
 #include "pycore_pylifecycle.h"   // _PyInterpreterConfig_AsDict()
-#include "pycore_pystate.h"       // _PyInterpreterState_SetRunningMain()
+#include "pycore_pystate.h"       // _PyInterpreterState_IsRunningMain()
 
 #include "marshal.h"              // PyMarshal_ReadObjectFromString()
 
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 92190b06829f8f..379f9869f2fe09 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -7,6 +7,7 @@
 #include "pycore_ceval.h"         // _PyEval_SetProfile()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_time.h"          // _PyTime_FromLong()
+#include "pycore_typeobject.h"    // _PyType_GetModuleState()
 #include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()
 
 #include "rotatingtree.h"
diff --git a/Modules/_testcapi/watchers.c b/Modules/_testcapi/watchers.c
index f7440769b9594e..6a5136ef8c9ecc 100644
--- a/Modules/_testcapi/watchers.c
+++ b/Modules/_testcapi/watchers.c
@@ -6,9 +6,9 @@
 #include "clinic/watchers.c.h"
 
 #define Py_BUILD_CORE
-#include "pycore_function.h"  // FUNC_MAX_WATCHERS
-#include "pycore_code.h"  // CODE_MAX_WATCHERS
-#include "pycore_context.h" // CONTEXT_MAX_WATCHERS
+#include "pycore_function.h"      // FUNC_MAX_WATCHERS
+#include "pycore_interp_structs.h" // CODE_MAX_WATCHERS
+#include "pycore_context.h"       // CONTEXT_MAX_WATCHERS
 
 /*[clinic input]
 module _testcapi
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index f927d13fc75e76..5f39ed11b57e5c 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -17,7 +17,7 @@
 #include "pycore_code.h"          // _PyCode_GetTLBCFast()
 #include "pycore_compile.h"       // _PyCompile_CodeGen()
 #include "pycore_context.h"       // _PyContext_NewHamtForTests()
-#include "pycore_dict.h"          // _PyManagedDictPointer_GetValues()
+#include "pycore_dict.h"          // PyDictValues
 #include "pycore_fileutils.h"     // _Py_normpath()
 #include "pycore_flowgraph.h"     // _PyCompile_OptimizeCfg()
 #include "pycore_frame.h"         // _PyInterpreterFrame
@@ -26,11 +26,11 @@
 #include "pycore_import.h"        // _PyImport_ClearExtension()
 #include "pycore_initconfig.h"    // _Py_GetConfigsAsDict()
 #include "pycore_instruction_sequence.h"  // _PyInstructionSequence_New()
+#include "pycore_interpframe.h"   // _PyFrame_GetFunction()
 #include "pycore_object.h"        // _PyObject_IsFreed()
-#include "pycore_optimizer.h"     // JitOptSymbol, etc.
 #include "pycore_pathconfig.h"    // _PyPathConfig_ClearGlobal()
 #include "pycore_pyerrors.h"      // _PyErr_ChainExceptions1()
-#include "pycore_pylifecycle.h"   // _PyInterpreterConfig_AsDict()
+#include "pycore_pylifecycle.h"   // _PyInterpreterConfig_InitFromDict()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_unicodeobject.h" // 
_PyUnicode_TransformDecimalAndSpaceToASCII()
 
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index b679b83bed5365..dc6485878b7cb4 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -8,7 +8,7 @@
 #include "pycore_ceval.h"         // _PyEval_SignalReceived()
 #include "pycore_emscripten_signal.h"  // _Py_CHECK_EMSCRIPTEN_SIGNALS
 #include "pycore_fileutils.h"     // _Py_BEGIN_SUPPRESS_IPH
-#include "pycore_frame.h"         // _PyInterpreterFrame
+#include "pycore_interpframe.h"   // _PyThreadState_GetFrame()
 #include "pycore_moduleobject.h"  // _PyModule_GetState()
 #include "pycore_pyerrors.h"      // _PyErr_SetString()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
diff --git a/Objects/abstract.c b/Objects/abstract.c
index ce006777e5c1dd..df96b935eccb44 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -5,10 +5,11 @@
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_ceval.h"         // _Py_EnterRecursiveCallTstate()
 #include "pycore_crossinterp.h"   // _Py_CallInInterpreter()
+#include "pycore_genobject.h"     // _PyGen_FetchStopIterationValue()
 #include "pycore_list.h"          // _PyList_AppendTakeRef()
-#include "pycore_long.h"          // _Py_IsNegative
+#include "pycore_long.h"          // _PyLong_IsNegative()
 #include "pycore_object.h"        // _Py_CheckSlotResult()
-#include "pycore_pybuffer.h"
+#include "pycore_pybuffer.h"      // _PyBuffer_ReleaseInInterpreterAndRawFree()
 #include "pycore_pyerrors.h"      // _PyErr_Occurred()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_tuple.h"         // _PyTuple_FromArraySteal()
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index f06b19b2fb775d..c55ab6b9b28e9e 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -2,16 +2,14 @@
 #include "opcode.h"
 
 #include "pycore_code.h"          // _PyCodeConstructor
-#include "pycore_frame.h"         // FRAME_SPECIALS_SIZE
 #include "pycore_hashtable.h"     // _Py_hashtable_t
-#include "pycore_index_pool.h"     // _PyIndexPool
+#include "pycore_index_pool.h"    // _PyIndexPool_Fini()
 #include "pycore_initconfig.h"    // _PyStatus_OK()
 #include "pycore_interp.h"        // PyInterpreterState.co_extra_freefuncs
-#include "pycore_object.h"        // _PyObject_SetDeferredRefcount
-#include "pycore_object_stack.h"
-#include "pycore_opcode_metadata.h" // _PyOpcode_Deopt, _PyOpcode_Caches
+#include "pycore_interpframe.h"   // FRAME_SPECIALS_SIZE
+#include "pycore_opcode_metadata.h" // _PyOpcode_Caches
 #include "pycore_opcode_utils.h"  // RESUME_AT_FUNC_START
-#include "pycore_pymem.h"         // _PyMem_FreeDelayed
+#include "pycore_pymem.h"         // _PyMem_FreeDelayed()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_setobject.h"     // _PySet_NextEntry()
 #include "pycore_tuple.h"         // _PyTuple_ITEMS()
diff --git a/Objects/iterobject.c b/Objects/iterobject.c
index 8693e0458d0e67..c023f41638f3d3 100644
--- a/Objects/iterobject.c
+++ b/Objects/iterobject.c
@@ -4,8 +4,10 @@
 #include "pycore_abstract.h"      // _PyObject_HasLen()
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_ceval.h"         // _PyEval_GetBuiltin()
+#include "pycore_genobject.h"     // _PyCoro_GetAwaitableIter()
 #include "pycore_object.h"        // _PyObject_GC_TRACK()
 
+
 typedef struct {
     PyObject_HEAD
     Py_ssize_t it_index;
diff --git a/Objects/object.c b/Objects/object.c
index 4eff24bc3a9507..ecc5a86901a347 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -6,29 +6,28 @@
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_ceval.h"         // _Py_EnterRecursiveCallTstate()
 #include "pycore_context.h"       // _PyContextTokenMissing_Type
-#include "pycore_critical_section.h"     // Py_BEGIN_CRITICAL_SECTION, 
Py_END_CRITICAL_SECTION
+#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION
 #include "pycore_descrobject.h"   // _PyMethodWrapper_Type
-#include "pycore_dict.h"          // _PyObject_MakeDictFromInstanceAttributes()
+#include "pycore_dict.h"          // _PyObject_MaterializeManagedDict()
 #include "pycore_floatobject.h"   // _PyFloat_DebugMallocStats()
 #include "pycore_freelist.h"      // _PyObject_ClearFreeLists()
+#include "pycore_genobject.h"     // _PyAsyncGenAThrow_Type
 #include "pycore_hamt.h"          // _PyHamtItems_Type
-#include "pycore_hashtable.h"     // _Py_hashtable_new()
-#include "pycore_initconfig.h"    // _PyStatus_EXCEPTION()
+#include "pycore_initconfig.h"    // _PyStatus_OK()
 #include "pycore_instruction_sequence.h" // _PyInstructionSequence_Type
 #include "pycore_list.h"          // _PyList_DebugMallocStats()
 #include "pycore_long.h"          // _PyLong_GetZero()
 #include "pycore_memoryobject.h"  // _PyManagedBuffer_Type
 #include "pycore_namespace.h"     // _PyNamespace_Type
-#include "pycore_object.h"        // PyAPI_DATA() _Py_SwappedOp definition
-#include "pycore_object_state.h"  // struct _reftracer_runtime_state
-#include "pycore_optimizer.h"     // _PyUOpExecutor_Type, ...
+#include "pycore_object.h"        // export _Py_SwappedOp
+#include "pycore_optimizer.h"     // _PyUOpExecutor_Type
 #include "pycore_pyerrors.h"      // _PyErr_Occurred()
 #include "pycore_pymem.h"         // _PyMem_IsPtrFreed()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_symtable.h"      // PySTEntry_Type
 #include "pycore_tuple.h"         // _PyTuple_DebugMallocStats()
 #include "pycore_typeobject.h"    // _PyBufferWrapper_Type
-#include "pycore_typevarobject.h" // _PyTypeAlias_Type, _Py_initialize_generic
+#include "pycore_typevarobject.h" // _PyTypeAlias_Type
 #include "pycore_unionobject.h"   // _PyUnion_Type
 
 
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index ede8fd219c4cf0..78ee3fa1fc3aad 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -1,17 +1,17 @@
-
 /* Tuple object implementation */
 
 #include "Python.h"
 #include "pycore_abstract.h"      // _PyIndex_Check()
 #include "pycore_ceval.h"         // _PyEval_GetBuiltin()
-#include "pycore_freelist.h"      // _Py_FREELIST_PUSH(), _Py_FREELIST_POP()
+#include "pycore_freelist.h"      // _Py_FREELIST_PUSH()
 #include "pycore_gc.h"            // _PyObject_GC_IS_TRACKED()
-#include "pycore_initconfig.h"    // _PyStatus_OK()
 #include "pycore_list.h"          // _Py_memory_repeat()
 #include "pycore_modsupport.h"    // _PyArg_NoKwnames()
-#include "pycore_object.h"        // _PyObject_GC_TRACK(), 
_Py_FatalRefcountError(), _PyDebugAllocatorStats()
+#include "pycore_object.h"        // _PyObject_GC_TRACK()
+#include "pycore_stackref.h"      // PyStackRef_AsPyObjectSteal()
 #include "pycore_tuple.h"         // _PyTupleIterObject
 
+
 /*[clinic input]
 class tuple "PyTupleObject *" "&PyTuple_Type"
 [clinic start generated code]*/
diff --git a/Parser/myreadline.c b/Parser/myreadline.c
index 99c5760cd51442..64e8f5383f0602 100644
--- a/Parser/myreadline.c
+++ b/Parser/myreadline.c
@@ -13,6 +13,7 @@
 #include "pycore_fileutils.h"     // _Py_BEGIN_SUPPRESS_IPH
 #include "pycore_interp.h"        // _PyInterpreterState_GetConfig()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_signal.h"        // _PyOS_SigintEvent()
 #ifdef MS_WINDOWS
 #  ifndef WIN32_LEAN_AND_MEAN
 #    define WIN32_LEAN_AND_MEAN
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 3271768e6f68f9..1e90ef0299c2e2 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -1,10 +1,9 @@
 #include "Python.h"
-#include "pycore_critical_section.h"  // Py_BEGIN_CRITICAL_SECTION_MUT()
 #include "pycore_frame.h"         // PyFrameObject members
+#include "pycore_genobject.h"     // PyAsyncGenObject
 #include "pycore_import.h"        // _PyImport_GetModules()
 #include "pycore_interp.h"        // PyInterpreterState.warnings
 #include "pycore_long.h"          // _PyLong_GetZero()
-#include "pycore_pyerrors.h"      // _PyErr_Occurred()
 #include "pycore_pylifecycle.h"   // _Py_IsInterpreterFinalizing()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_sysmodule.h"     // _PySys_GetOptionalAttr()
diff --git a/Python/ceval.c b/Python/ceval.c
index 0090a2c79ec7ef..363f263ad2a083 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -10,11 +10,15 @@
 #include "pycore_cell.h"          // PyCell_GetRef()
 #include "pycore_ceval.h"
 #include "pycore_code.h"
+#include "pycore_dict.h"
 #include "pycore_emscripten_signal.h"  // _Py_CHECK_EMSCRIPTEN_SIGNALS
 #include "pycore_floatobject.h"   // _PyFloat_ExactDealloc()
+#include "pycore_frame.h"
 #include "pycore_function.h"
+#include "pycore_genobject.h"     // _PyCoro_GetAwaitableIter()
 #include "pycore_import.h"        // _PyImport_IsDefaultImportFunc()
 #include "pycore_instruments.h"
+#include "pycore_interpframe.h"   // _PyFrame_SetStackPointer()
 #include "pycore_intrinsics.h"
 #include "pycore_jit.h"
 #include "pycore_list.h"          // _PyList_GetItemRef()
@@ -22,23 +26,21 @@
 #include "pycore_moduleobject.h"  // PyModuleObject
 #include "pycore_object.h"        // _PyObject_GC_TRACK()
 #include "pycore_opcode_metadata.h" // EXTRA_CASES
-#include "pycore_optimizer.h"     // _PyUOpExecutor_Type
 #include "pycore_opcode_utils.h"  // MAKE_FUNCTION_*
+#include "pycore_optimizer.h"     // _PyUOpExecutor_Type
 #include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_*
+#include "pycore_pyerrors.h"
 #include "pycore_pyerrors.h"      // _PyErr_GetRaisedException()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_range.h"         // _PyRangeIterObject
 #include "pycore_setobject.h"     // _PySet_Update()
 #include "pycore_sliceobject.h"   // _PyBuildSlice_ConsumeRefs
+#include "pycore_sysmodule.h"     // _PySys_GetOptionalAttrString()
 #include "pycore_traceback.h"     // _PyTraceBack_FromFrame
 #include "pycore_tuple.h"         // _PyTuple_ITEMS()
 #include "pycore_uop_ids.h"       // Uops
-#include "pycore_pyerrors.h"
-#include "pycore_sysmodule.h"     // _PySys_GetOptionalAttrString()
 
-#include "pycore_dict.h"
 #include "dictobject.h"
-#include "pycore_frame.h"
 #include "frameobject.h"          // _PyInterpreterFrame_GetLine
 #include "opcode.h"
 #include "pydtrace.h"
diff --git a/Python/ceval_gil.c b/Python/ceval_gil.c
index a382aa6f1e1a09..77632b283b256c 100644
--- a/Python/ceval_gil.c
+++ b/Python/ceval_gil.c
@@ -1,14 +1,12 @@
-
 #include "Python.h"
 #include "pycore_ceval.h"         // _PyEval_SignalReceived()
+#include "pycore_gc.h"            // _Py_RunGC()
 #include "pycore_initconfig.h"    // _PyStatus_OK()
-#include "pycore_interp.h"        // _Py_RunGC()
 #include "pycore_optimizer.h"     // _Py_Executors_InvalidateCold()
 #include "pycore_pyerrors.h"      // _PyErr_GetRaisedException()
 #include "pycore_pylifecycle.h"   // _PyErr_Print()
-#include "pycore_pymem.h"         // _PyMem_IsPtrFreed()
-#include "pycore_pystate.h"       // PyThread_hang_thread()
 #include "pycore_pystats.h"       // _Py_PrintSpecializationStats()
+#include "pycore_runtime.h"       // _PyRuntime
 
 
 /*
diff --git a/Python/crossinterp.c b/Python/crossinterp.c
index aa2c1cb78bce06..094bbbe54f2a75 100644
--- a/Python/crossinterp.c
+++ b/Python/crossinterp.c
@@ -5,8 +5,8 @@
 #include "pycore_ceval.h"         // _Py_simple_func
 #include "pycore_crossinterp.h"   // _PyXIData_t
 #include "pycore_initconfig.h"    // _PyStatus_OK()
-#include "pycore_namespace.h"     //_PyNamespace_New()
-#include "pycore_pyerrors.h"      // _PyErr_Clear()
+#include "pycore_namespace.h"     // _PyNamespace_New()
+#include "pycore_typeobject.h"    // _PyStaticType_InitBuiltin()
 
 
 /**************/
diff --git a/Python/gc.c b/Python/gc.c
index ff0fa636bd68f8..a2ec0e567b5e39 100644
--- a/Python/gc.c
+++ b/Python/gc.c
@@ -4,19 +4,18 @@
 
 #include "Python.h"
 #include "pycore_ceval.h"         // _Py_set_eval_breaker_bit()
-#include "pycore_context.h"
 #include "pycore_dict.h"          // _PyInlineValuesSize()
-#include "pycore_initconfig.h"
+#include "pycore_initconfig.h"    // _PyStatus_OK()
 #include "pycore_interp.h"        // PyInterpreterState.gc
-#include "pycore_object.h"
+#include "pycore_interpframe.h"   // _PyFrame_GetLocalsArray()
 #include "pycore_object_alloc.h"  // _PyObject_MallocWithType()
-#include "pycore_pyerrors.h"
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_tuple.h"         // _PyTuple_MaybeUntrack()
 #include "pycore_weakref.h"       // _PyWeakref_ClearRef()
 
 #include "pydtrace.h"
 
+
 #ifndef Py_GIL_DISABLED
 
 typedef struct _gc_runtime_state GCState;
diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c
index 713a48744df3a1..70dace9fe9eff2 100644
--- a/Python/gc_free_threading.c
+++ b/Python/gc_free_threading.c
@@ -5,8 +5,10 @@
 #include "pycore_dict.h"          // _PyInlineValuesSize()
 #include "pycore_frame.h"         // FRAME_CLEARED
 #include "pycore_freelist.h"      // _PyObject_ClearFreeLists()
+#include "pycore_genobject.h"     // _PyGen_GetGeneratorFromFrame()
 #include "pycore_initconfig.h"    // _PyStatus_NO_MEMORY()
 #include "pycore_interp.h"        // PyInterpreterState.gc
+#include "pycore_interpframe.h"   // _PyFrame_GetLocalsArray()
 #include "pycore_object_alloc.h"  // _PyObject_MallocWithType()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_tstate.h"        // _PyThreadStateImpl
diff --git a/Python/instrumentation.c b/Python/instrumentation.c
index 031c450bb600ba..9bf0fc43556803 100644
--- a/Python/instrumentation.c
+++ b/Python/instrumentation.c
@@ -1,22 +1,20 @@
 #include "Python.h"
-#include "pycore_bitutils.h"      // _Py_popcount32
-#include "pycore_call.h"
+#include "pycore_bitutils.h"      // _Py_popcount32()
+#include "pycore_call.h"          // _PyObject_VectorcallTstate()
 #include "pycore_ceval.h"         // _PY_EVAL_EVENTS_BITS
 #include "pycore_code.h"          // _PyCode_Clear_Executors()
-#include "pycore_critical_section.h"
-#include "pycore_frame.h"
-#include "pycore_interp.h"
-#include "pycore_long.h"
+#include "pycore_critical_section.h" // 
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED()
+#include "pycore_frame.h"         // PyFrameObject
+#include "pycore_interpframe.h"   // _PyFrame_GetBytecode()
+#include "pycore_long.h"          // _PyLong_GetZero()
 #include "pycore_modsupport.h"    // _PyModule_CreateInitialized()
-#include "pycore_namespace.h"
-#include "pycore_object.h"
-#include "pycore_opcode_metadata.h" // IS_VALID_OPCODE, _PyOpcode_Caches
-#include "pycore_opcode_utils.h" // IS_CONDITIONAL_JUMP_OPCODE
+#include "pycore_namespace.h"     // _PyNamespace_New()
+#include "pycore_opcode_metadata.h" // IS_VALID_OPCODE()
+#include "pycore_opcode_utils.h"  // IS_CONDITIONAL_JUMP_OPCODE()
 #include "pycore_optimizer.h"     // _PyExecutorObject
-#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_STORE_UINTPTR_RELEASE
-#include "pycore_pyerrors.h"
+#include "pycore_pyatomic_ft_wrappers.h" // FT_ATOMIC_STORE_UINTPTR_RELEASE()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
-#include "pycore_runtime_structs.h"  // _PyCoMonitoringData
+#include "pycore_runtime_structs.h" // _PyCoMonitoringData
 #include "pycore_tuple.h"         // _PyTuple_FromArraySteal()
 
 #include "opcode_ids.h"
diff --git a/Python/legacy_tracing.c b/Python/legacy_tracing.c
index 924e7e5ca01942..bafc2356280b37 100644
--- a/Python/legacy_tracing.c
+++ b/Python/legacy_tracing.c
@@ -6,11 +6,12 @@
 #include "pycore_audit.h"         // _PySys_Audit()
 #include "pycore_ceval.h"         // export _PyEval_SetProfile()
 #include "pycore_frame.h"         // PyFrameObject members
-#include "pycore_object.h"
+#include "pycore_interpframe.h"   // _PyFrame_GetCode()
 
 #include "opcode.h"
 #include <stddef.h>
 
+
 typedef struct _PyLegacyEventHandler {
     PyObject_HEAD
     vectorcallfunc vectorcall;
diff --git a/Python/perf_trampoline.c b/Python/perf_trampoline.c
index a6a32b98fa9ef5..996e54b82b61e8 100644
--- a/Python/perf_trampoline.c
+++ b/Python/perf_trampoline.c
@@ -131,8 +131,7 @@ any DWARF information available for them).
 
 #include "Python.h"
 #include "pycore_ceval.h"         // _PyPerf_Callbacks
-#include "pycore_frame.h"
-#include "pycore_interp.h"
+#include "pycore_interpframe.h"   // _PyFrame_GetCode()
 #include "pycore_runtime.h"       // _PyRuntime
 
 
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 12a48316cbc243..8fe58c320a33b2 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1,6 +1,8 @@
 /* Python interpreter top-level routines, including init/exit */
 
 #include "Python.h"
+#include "pycore_genobject.h"     // included first to break dependency cycle
+
 #include "pycore_audit.h"         // _PySys_ClearAuditHooks()
 #include "pycore_call.h"          // _PyObject_CallMethod()
 #include "pycore_ceval.h"         // _PyEval_FiniGIL()
@@ -12,10 +14,7 @@
 #include "pycore_floatobject.h"   // _PyFloat_InitTypes()
 #include "pycore_freelist.h"      // _PyObject_ClearFreeLists()
 #include "pycore_global_objects_fini_generated.h"  // 
_PyStaticObjects_CheckRefcnt()
-#include "pycore_hamt.h"          // _PyHamt_Type
-#include "pycore_import.h"        // _PyImport_BootstrapImp()
 #include "pycore_initconfig.h"    // _PyStatus_OK()
-#include "pycore_list.h"          // _PyList_Fini()
 #include "pycore_long.h"          // _PyLong_InitTypes()
 #include "pycore_object.h"        // _PyDebug_PrintTotalRefs()
 #include "pycore_obmalloc.h"      // _PyMem_init_obmalloc()
@@ -26,9 +25,7 @@
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_runtime.h"       // _Py_ID()
 #include "pycore_runtime_init.h"  // _PyRuntimeState_INIT
-#include "pycore_runtime_structs.h"
 #include "pycore_setobject.h"     // _PySet_NextEntry()
-#include "pycore_sliceobject.h"   // _PySlice_Fini()
 #include "pycore_sysmodule.h"     // _PySys_ClearAttrString()
 #include "pycore_traceback.h"     // _Py_DumpTracebackThreads()
 #include "pycore_typeobject.h"    // _PyTypes_InitTypes()
diff --git a/Python/pystate.c b/Python/pystate.c
index c755e0d9f27cc7..7d1ca0d33ef4d8 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -2,33 +2,32 @@
 /* Thread and interpreter state structures and their interfaces */
 
 #include "Python.h"
-#include "pycore_runtime_structs.h"
+#include "pycore_genobject.h"     // included first to break dependency cycle
 
 #include "pycore_abstract.h"      // _PyIndex_Check()
 #include "pycore_audit.h"         // _Py_AuditHookEntry
-#include "pycore_ceval.h"
-#include "pycore_code.h"          // stats
+#include "pycore_ceval.h"         // _PyEval_AcquireLock()
 #include "pycore_codecs.h"        // _PyCodec_Fini()
-#include "pycore_critical_section.h"       // _PyCriticalSection_Resume()
+#include "pycore_critical_section.h" // _PyCriticalSection_Resume()
 #include "pycore_dtoa.h"          // _dtoa_state_INIT()
-#include "pycore_emscripten_trampoline.h"  // _Py_EmscriptenTrampoline_Init()
-#include "pycore_frame.h"
+#include "pycore_emscripten_trampoline.h" // _Py_EmscriptenTrampoline_Init()
 #include "pycore_freelist.h"      // _PyObject_ClearFreeLists()
 #include "pycore_initconfig.h"    // _PyStatus_OK()
+#include "pycore_interpframe.h"   // _PyThreadState_HasStackSpace()
 #include "pycore_object.h"        // _PyType_InitCache()
+#include "pycore_obmalloc.h"      // _PyMem_obmalloc_state_on_heap()
 #include "pycore_optimizer.h"     // JIT_CLEANUP_THRESHOLD
 #include "pycore_parking_lot.h"   // _PyParkingLot_AfterFork()
 #include "pycore_pyerrors.h"      // _PyErr_Clear()
 #include "pycore_pylifecycle.h"   // _PyAST_Fini()
 #include "pycore_pymem.h"         // _PyMem_DebugEnabled()
-#include "pycore_pystate.h"
 #include "pycore_runtime.h"       // _PyRuntime
 #include "pycore_runtime_init.h"  // _PyRuntimeState_INIT
 #include "pycore_stackref.h"      // Py_STACKREF_DEBUG
 #include "pycore_time.h"          // _PyTime_Init()
-#include "pycore_obmalloc.h"      // _PyMem_obmalloc_state_on_heap()
 #include "pycore_uniqueid.h"      // _PyObject_FinalizePerThreadRefcounts()
 
+
 /* --------------------------------------------------------------------------
 CAUTION
 
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 0fe9f894f05af4..664bf31e9ecd9b 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -18,10 +18,10 @@ Data members:
 #include "pycore_audit.h"         // _Py_AuditHookEntry
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_ceval.h"         // _PyEval_SetAsyncGenFinalizer()
-#include "pycore_dict.h"          // _PyDict_GetItemWithError()
 #include "pycore_frame.h"         // _PyInterpreterFrame
 #include "pycore_import.h"        // _PyImport_SetDLOpenFlags()
 #include "pycore_initconfig.h"    // _PyStatus_EXCEPTION()
+#include "pycore_interpframe.h"   // _PyFrame_GetFirstComplete()
 #include "pycore_long.h"          // _PY_LONG_MAX_STR_DIGITS_THRESHOLD
 #include "pycore_modsupport.h"    // _PyModule_CreateInitialized()
 #include "pycore_namespace.h"     // _PyNamespace_New()
@@ -36,7 +36,6 @@ Data members:
 #include "pycore_pystats.h"       // _Py_PrintSpecializationStats()
 #include "pycore_structseq.h"     // _PyStructSequence_InitBuiltinWithFlags()
 #include "pycore_sysmodule.h"     // export _PySys_GetSizeOf()
-#include "pycore_tuple.h"         // _PyTuple_FromArray()
 #include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal()
 
 #include "pydtrace.h"             // PyDTrace_AUDIT()
diff --git a/Python/traceback.c b/Python/traceback.c
index 07a7ca8e7d63e4..ff6f9b9a6abd37 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -2,14 +2,11 @@
 /* Traceback implementation */
 
 #include "Python.h"
-
-#include "pycore_ast.h"           // asdl_seq_GET()
 #include "pycore_call.h"          // _PyObject_CallMethodFormat()
 #include "pycore_fileutils.h"     // _Py_BEGIN_SUPPRESS_IPH
-#include "pycore_frame.h"         // _PyFrame_GetCode()
+#include "pycore_frame.h"         // PyFrameObject
 #include "pycore_interp.h"        // PyInterpreterState.gc
-#include "pycore_parser.h"        // _PyParser_ASTFromString
-#include "pycore_pyarena.h"       // _PyArena_Free()
+#include "pycore_interpframe.h"   // _PyFrame_GetCode()
 #include "pycore_pyerrors.h"      // _PyErr_GetRaisedException()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_sysmodule.h"     // _PySys_GetOptionalAttr()

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to