Skip to content

gh-131238: Remove pycore_runtime.h from pycore_pystate.h #131356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
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
1 change: 1 addition & 0 deletions Include/internal/pycore_call.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

#include "pycore_code.h" // EVAL_CALL_STAT_INC_IF_FUNCTION()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_stats.h"

Expand Down
4 changes: 3 additions & 1 deletion Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ extern "C" {
#include "pycore_warnings.h" // struct _warnings_runtime_state



/* interpreter state */

#define _PyInterpreterState_WHENCE_NOTSET -1
Expand Down Expand Up @@ -134,6 +133,9 @@ PyAPI_FUNC(PyStatus) _PyInterpreterState_New(
PyThreadState *tstate,
PyInterpreterState **pinterp);

extern const PyConfig* _PyInterpreterState_GetConfig(
PyInterpreterState *interp);

#ifdef __cplusplus
}
#endif
Expand Down
12 changes: 3 additions & 9 deletions Include/internal/pycore_interp_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ extern "C" {
#endif

#include "pycore_ast_state.h" // struct ast_state
#include "pycore_llist.h"
#include "pycore_llist.h" // struct llist_node
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
#include "pycore_structs.h"
#include "pycore_structs.h" // PyHamtObject
#include "pycore_tstate.h" // _PyThreadStateImpl
#include "pycore_typedefs.h" // _PyRuntimeState


Expand Down Expand Up @@ -246,13 +247,6 @@ struct _gc_runtime_state {
#endif
};

#ifdef Py_GIL_DISABLED
struct _gc_thread_state {
/* Thread-local allocation count. */
Py_ssize_t alloc_count;
};
#endif

#include "pycore_gil.h"

/****** Thread state **************/
Expand Down
5 changes: 1 addition & 4 deletions Include/internal/pycore_pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

#include "pycore_runtime_structs.h" // _PyRuntime
#include "pycore_runtime.h" // _PyRuntimeState_GetFinalizing
#include "pycore_tstate.h" // _PyThreadStateImpl
#include "pycore_typedefs.h" // _PyRuntimeState

extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp);

// Values for PyThreadState.state. A thread must be in the "attached" state
// before calling most Python APIs. If the GIL is enabled, then "attached"
Expand Down
7 changes: 7 additions & 0 deletions Include/internal/pycore_tstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ extern "C" {
#include "pycore_qsbr.h" // struct qsbr


#ifdef Py_GIL_DISABLED
struct _gc_thread_state {
/* Thread-local allocation count. */
Py_ssize_t alloc_count;
};
#endif

// Every PyThreadState is actually allocated as a _PyThreadStateImpl. The
// PyThreadState fields are exposed as part of the C API, although most fields
// are intended to be private. The _PyThreadStateImpl fields not exposed.
Expand Down
2 changes: 2 additions & 0 deletions Include/internal/pycore_tuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ extern "C" {
# error "this header requires Py_BUILD_CORE define"
#endif

#include "pycore_structs.h" // _PyStackRef

extern void _PyTuple_MaybeUntrack(PyObject *);
extern void _PyTuple_DebugMallocStats(FILE *out);

Expand Down
4 changes: 2 additions & 2 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1305,25 +1305,25 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_sliceobject.h \
$(srcdir)/Include/internal/pycore_stats.h \
$(srcdir)/Include/internal/pycore_strhex.h \
$(srcdir)/Include/internal/pycore_stackref.h \
$(srcdir)/Include/internal/pycore_structs.h \
$(srcdir)/Include/internal/pycore_structseq.h \
$(srcdir)/Include/internal/pycore_symtable.h \
$(srcdir)/Include/internal/pycore_sysmodule.h \
$(srcdir)/Include/internal/pycore_stackref.h \
$(srcdir)/Include/internal/pycore_time.h \
$(srcdir)/Include/internal/pycore_token.h \
$(srcdir)/Include/internal/pycore_traceback.h \
$(srcdir)/Include/internal/pycore_tracemalloc.h \
$(srcdir)/Include/internal/pycore_tstate.h \
$(srcdir)/Include/internal/pycore_tuple.h \
$(srcdir)/Include/internal/pycore_typedefs.h \
$(srcdir)/Include/internal/pycore_uniqueid.h \
$(srcdir)/Include/internal/pycore_typeobject.h \
$(srcdir)/Include/internal/pycore_typevarobject.h \
$(srcdir)/Include/internal/pycore_ucnhash.h \
$(srcdir)/Include/internal/pycore_unicodeobject.h \
$(srcdir)/Include/internal/pycore_unicodeobject_generated.h \
$(srcdir)/Include/internal/pycore_unionobject.h \
$(srcdir)/Include/internal/pycore_uniqueid.h \
$(srcdir)/Include/internal/pycore_uop_ids.h \
$(srcdir)/Include/internal/pycore_uop_metadata.h \
$(srcdir)/Include/internal/pycore_warnings.h \
Expand Down
5 changes: 4 additions & 1 deletion Modules/_testinternalcapi/test_critical_sections.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
*/

#include "parts.h"

#include "pycore_critical_section.h"

#ifdef MS_WINDOWS
# include <windows.h> // Sleep()
#endif

#ifdef Py_GIL_DISABLED
#define assert_nogil assert
#define assert_gil(x)
Expand Down
7 changes: 3 additions & 4 deletions Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@
#include "pycore_moduleobject.h" // _PyModule_GetState()
#include "pycore_pylifecycle.h" // _Py_IsInterpreterFinalizing()
#include "pycore_pystate.h" // _PyInterpreterState_GET
#include "pycore_unicodeobject.h" // _PyUnicode_WideCharString_Opt_Converter

#include "pycore_unicodeobject.h" // for Argument Clinic


#ifndef WINDOWS_LEAN_AND_MEAN
#define WINDOWS_LEAN_AND_MEAN
# define WINDOWS_LEAN_AND_MEAN
#endif
#include "windows.h"
#include <windows.h>
#include <winioctl.h>
#include <crtdbg.h>
#include "winreparse.h"
Expand Down
1 change: 1 addition & 0 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
<ClInclude Include="..\Include\internal\pycore_initconfig.h" />
<ClInclude Include="..\Include\internal\pycore_instruction_sequence.h" />
<ClInclude Include="..\Include\internal\pycore_interp.h" />
<ClInclude Include="..\Include\internal\pycore_interp_structs.h" />
<ClInclude Include="..\Include\internal\pycore_intrinsics.h" />
<ClInclude Include="..\Include\internal\pycore_jit.h" />
<ClInclude Include="..\Include\internal\pycore_list.h" />
Expand Down
9 changes: 9 additions & 0 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@
<ClInclude Include="..\Include\internal\pycore_interp.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_interp_structs.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_intrinsics.h">
<Filter>Include\cpython</Filter>
</ClInclude>
Expand Down Expand Up @@ -801,6 +804,9 @@
<ClInclude Include="..\Include\internal\pycore_runtime_init_generated.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_runtime_structs.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_semaphore.h">
<Filter>Include\internal</Filter>
</ClInclude>
Expand All @@ -816,6 +822,9 @@
<ClInclude Include="..\Include\internal\pycore_strhex.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_structs.h">
<Filter>Include\internal</Filter>
</ClInclude>
<ClInclude Include="..\Include\internal\pycore_sysmodule.h">
<Filter>Include\internal</Filter>
</ClInclude>
Expand Down
7 changes: 3 additions & 4 deletions Parser/action_helpers.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#include <Python.h>
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_runtime.h" // _PyRuntime
#include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal()

#include "pegen.h"
#include "string_parser.h" // _PyPegen_decode_string()

#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal()
#include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal()


void *
_PyPegen_dummy_name(Parser *p, ...)
Expand Down
3 changes: 2 additions & 1 deletion Parser/myreadline.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

#include "Python.h"
#include "pycore_fileutils.h" // _Py_BEGIN_SUPPRESS_IPH
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_interp.h" // _PyInterpreterState_GetConfig()
#include "pycore_pystate.h" // _PyThreadState_GET()
#ifdef MS_WINDOWS
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
Expand Down
1 change: 1 addition & 0 deletions Python/bltinmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "pycore_ceval.h" // _PyEval_Vector()
#include "pycore_compile.h" // _PyAST_Compile()
#include "pycore_fileutils.h" // _PyFile_Flush
#include "pycore_interp.h" // _PyInterpreterState_GetConfig()
#include "pycore_long.h" // _PyLong_CompactValue
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
#include "pycore_object.h" // _Py_AddToAllObjects()
Expand Down
3 changes: 2 additions & 1 deletion Python/dynload_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

#include "Python.h"
#include "pycore_fileutils.h" // _Py_add_relfile()
#include "pycore_importdl.h" // dl_funcptr
#include "pycore_interp.h" // _PyInterpreterState_GetConfig()
#include "pycore_pystate.h" // _PyInterpreterState_GET()

#include "pycore_importdl.h" // dl_funcptr
#include "patchlevel.h" // PY_MAJOR_VERSION
#include <windows.h>

Expand Down
3 changes: 2 additions & 1 deletion Python/pytime.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "Python.h"
#include "pycore_initconfig.h" // _PyStatus_ERR
#include "pycore_time.h" // PyTime_t
#include "pycore_pystate.h" // _Py_AssertHoldsTstate()
#include "pycore_runtime.h" // _PyRuntime
#include "pycore_time.h" // PyTime_t

#include <time.h> // gmtime_r()
#ifdef HAVE_SYS_TIME_H
Expand Down
Loading