Skip to content

Commit 978e37b

Browse files
authored
pythongh-131238: Add explicit includes to pycore headers (python#131257)
1 parent 0453e49 commit 978e37b

23 files changed

+80
-45
lines changed

Modules/_io/_iomodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "Python.h"
1111
#include "pycore_abstract.h" // _PyNumber_Index()
12-
#include "pycore_initconfig.h" // _PyStatus_OK()
12+
#include "pycore_interp.h" // _PyInterpreterState_GetConfig()
1313
#include "pycore_long.h" // _PyLong_IsNegative()
1414
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
1515
#include "pycore_pystate.h" // _PyInterpreterState_GET()

Modules/_operator.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#include "Python.h"
22
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
33
#include "pycore_moduleobject.h" // _PyModule_GetState()
4-
#include "pycore_runtime.h" // _Py_ID()
54
#include "pycore_pystate.h" // _PyInterpreterState_GET()
5+
#include "pycore_tuple.h" // _PyTuple_ITEMS()
6+
#include "pycore_typeobject.h" // _PyType_GetModuleState()
7+
#include "pycore_unicodeobject.h" // _PyUnicode_InternMortal()
68

79

810
#include "clinic/_operator.c.h"

Modules/_posixsubprocess.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
#endif
55

66
#include "Python.h"
7-
#include "pycore_fileutils.h"
8-
#include "pycore_pystate.h"
7+
#include "pycore_interp.h" // _PyInterpreterState_GetFinalizing()
8+
#include "pycore_pystate.h" // _PyInterpreterState_GET()
99
#include "pycore_signal.h" // _Py_RestoreSignals()
10+
1011
#if defined(HAVE_PIPE2) && !defined(_GNU_SOURCE)
1112
# define _GNU_SOURCE
1213
#endif

Modules/_zoneinfo.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
#include "pycore_critical_section.h" // _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED()
77
#include "pycore_long.h" // _PyLong_GetOne()
88
#include "pycore_pyerrors.h" // _PyErr_ChainExceptions1()
9+
#include "pycore_typeobject.h" // _PyType_GetModuleState()
910

1011
#include "datetime.h" // PyDateTime_TZInfo
1112

1213
#include <stddef.h> // offsetof()
13-
#include <stdint.h>
14+
#include <stdint.h> // int64_t
15+
1416

1517
#include "clinic/_zoneinfo.c.h"
1618
/*[clinic input]

Modules/faulthandler.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "Python.h"
2-
#include "pycore_ceval.h" // _PyEval_IsGILEnabled
3-
#include "pycore_initconfig.h" // _PyStatus_ERR
4-
#include "pycore_pyerrors.h" // _Py_DumpExtensionModules
2+
#include "pycore_ceval.h" // _PyEval_IsGILEnabled()
3+
#include "pycore_initconfig.h" // _PyStatus_ERR()
4+
#include "pycore_pyerrors.h" // _Py_DumpExtensionModules()
55
#include "pycore_pystate.h" // _PyThreadState_GET()
6+
#include "pycore_runtime.h" // _Py_ID()
67
#include "pycore_signal.h" // Py_NSIG
78
#include "pycore_sysmodule.h" // _PySys_GetRequiredAttr()
89
#include "pycore_time.h" // _PyTime_FromSecondsObject()
@@ -28,6 +29,7 @@
2829
# include <sys/auxv.h> // getauxval()
2930
#endif
3031

32+
3133
/* Sentinel to ignore all_threads on free-threading */
3234
#define FT_IGNORE_ALL_THREADS 2
3335

Objects/fileobject.c

+2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
#include "Python.h"
44
#include "pycore_call.h" // _PyObject_CallNoArgs()
55
#include "pycore_runtime.h" // _PyRuntime
6+
#include "pycore_unicodeobject.h" // _PyUnicode_AsUTF8String()
67

78
#ifdef HAVE_UNISTD_H
89
# include <unistd.h> // isatty()
910
#endif
1011

12+
1113
#if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER)
1214
/* clang MemorySanitizer doesn't yet understand getc_unlocked. */
1315
# define GETC(f) getc_unlocked(f)

Parser/action_helpers.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#include <Python.h>
22

33
#include "pegen.h"
4-
#include "string_parser.h"
5-
#include "pycore_runtime.h" // _PyRuntime
4+
#include "string_parser.h" // _PyPegen_decode_string()
5+
66
#include "pycore_pystate.h" // _PyInterpreterState_GET()
7+
#include "pycore_runtime.h" // _PyRuntime
8+
#include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal()
9+
710

811
void *
912
_PyPegen_dummy_name(Parser *p, ...)

Parser/asdl_c.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -2273,15 +2273,16 @@ def generate_module_def(mod, metadata, f, internal_h):
22732273
#include "Python.h"
22742274
#include "pycore_ast.h"
22752275
#include "pycore_ast_state.h" // struct ast_state
2276-
#include "pycore_ceval.h" // _Py_EnterRecursiveCall
2276+
#include "pycore_ceval.h" // _Py_EnterRecursiveCall()
22772277
#include "pycore_lock.h" // _PyOnceFlag
2278-
#include "pycore_interp.h" // _PyInterpreterState.ast
22792278
#include "pycore_modsupport.h" // _PyArg_NoPositional()
22802279
#include "pycore_pystate.h" // _PyInterpreterState_GET()
2281-
#include "pycore_setobject.h" // _PySet_NextEntry(), _PySet_Update()
2280+
#include "pycore_runtime.h" // _Py_ID()
2281+
#include "pycore_setobject.h" // _PySet_NextEntry()
22822282
#include "pycore_unionobject.h" // _Py_union_type_or
2283-
#include "structmember.h"
2284-
#include <stddef.h>
2283+
2284+
#include <stddef.h> // offsetof()
2285+
22852286
22862287
// Forward declaration
22872288
static int init_types(void *arg);

Parser/tokenizer/file_tokenizer.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "Python.h"
2-
#include "pycore_call.h"
3-
#include "pycore_import.h"
4-
#include "pycore_fileutils.h"
5-
#include "errcode.h"
2+
#include "pycore_call.h" // _PyObject_CallNoArgs()
3+
#include "pycore_fileutils.h" // _Py_UniversalNewlineFgetsWithSize()
4+
#include "pycore_runtime.h" // _Py_ID()
5+
6+
#include "errcode.h" // E_NOMEM
67

78
#ifdef HAVE_UNISTD_H
89
# include <unistd.h> // lseek(), read()
@@ -13,6 +14,7 @@
1314
#include "../lexer/lexer.h"
1415
#include "../lexer/buffer.h"
1516

17+
1618
static int
1719
tok_concatenate_interactive_new_line(struct tok_state *tok, const char *line) {
1820
assert(tok->fp_interactive);

Python/Python-ast.c

+6-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/ast.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
#include "Python.h"
66
#include "pycore_ast.h" // asdl_stmt_seq
77
#include "pycore_pystate.h" // _PyThreadState_GET()
8+
#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()
9+
10+
#include <stdbool.h> // bool
811

9-
#include <assert.h>
10-
#include <stdbool.h>
1112

1213
#define ENTER_RECURSIVE() \
1314
if (Py_EnterRecursiveCall(" during compilation")) { \

Python/ast_opt.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
#include "Python.h"
33
#include "pycore_ast.h" // _PyAST_GetDocString()
44
#include "pycore_format.h" // F_LJUST
5-
#include "pycore_long.h" // _PyLong
6-
#include "pycore_pystate.h" // _PyThreadState_GET()
7-
#include "pycore_setobject.h" // _PySet_NextEntry()
5+
#include "pycore_runtime.h" // _Py_STR()
6+
#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()
87

98

109
typedef struct {

Python/codecs.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ Copyright (c) Corporation for National Research Initiatives.
1111
#include "Python.h"
1212
#include "pycore_call.h" // _PyObject_CallNoArgs()
1313
#include "pycore_interp.h" // PyInterpreterState.codec_search_path
14-
#include "pycore_lock.h" // PyMutex
1514
#include "pycore_pyerrors.h" // _PyErr_FormatNote()
1615
#include "pycore_pystate.h" // _PyInterpreterState_GET()
16+
#include "pycore_runtime.h" // _Py_ID()
1717
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
1818

19+
1920
static const char *codecs_builtin_error_handlers[] = {
2021
"strict", "ignore", "replace",
2122
"xmlcharrefreplace", "backslashreplace", "namereplace",

Python/compile.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@
1515
*/
1616

1717
#include "Python.h"
18-
#include "pycore_ast.h" // PyAST_Check, _PyAST_GetDocString()
18+
#include "pycore_ast.h" // PyAST_Check()
19+
#include "pycore_code.h" // _PyCode_GetFreevars()
1920
#include "pycore_compile.h"
20-
#include "pycore_flowgraph.h"
21+
#include "pycore_flowgraph.h" // _PyCfg_FromInstructionSequence()
2122
#include "pycore_pystate.h" // _Py_GetConfig()
23+
#include "pycore_runtime.h" // _Py_ID()
2224
#include "pycore_setobject.h" // _PySet_NextEntry()
25+
#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()
2326

2427
#include "cpython/code.h"
2528

2629
#include <stdbool.h>
2730

31+
2832
#undef SUCCESS
2933
#undef ERROR
3034
#define SUCCESS 0

Python/dtoa.c

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119

120120
#include "Python.h"
121121
#include "pycore_dtoa.h" // _PY_SHORT_FLOAT_REPR
122+
#include "pycore_interp_structs.h"// struct Bigint
122123
#include "pycore_pystate.h" // _PyInterpreterState_GET()
123124
#include <stdlib.h> // exit()
124125

Python/errors.c

+3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
#include "pycore_initconfig.h" // _PyStatus_ERR()
88
#include "pycore_pyerrors.h" // _PyErr_Format()
99
#include "pycore_pystate.h" // _PyThreadState_GET()
10+
#include "pycore_runtime.h" // _Py_ID()
1011
#include "pycore_structseq.h" // _PyStructSequence_FiniBuiltin()
1112
#include "pycore_sysmodule.h" // _PySys_GetOptionalAttr()
1213
#include "pycore_traceback.h" // _PyTraceBack_FromFrame()
14+
#include "pycore_unicodeobject.h" // _PyUnicode_Equal()
1315

1416
#ifdef MS_WINDOWS
1517
# include <windows.h>
1618
# include <winbase.h>
1719
# include <stdlib.h> // _sys_nerr
1820
#endif
1921

22+
2023
/* Forward declarations */
2124
static PyObject *
2225
_PyErr_FormatV(PyThreadState *tstate, PyObject *exception,

Python/importdl.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
/* Support for dynamic loading of extension modules */
33

44
#include "Python.h"
5-
#include "pycore_call.h"
6-
#include "pycore_import.h"
5+
#include "pycore_call.h" // _PyObject_CallMethod()
6+
#include "pycore_import.h" // _PyImport_SwapPackageContext()
7+
#include "pycore_importdl.h" // struct _Py_ext_module_loader_info
8+
#include "pycore_moduleobject.h" // _PyModule_GetDef()
79
#include "pycore_pyerrors.h" // _PyErr_FormatFromCause()
8-
#include "pycore_pystate.h"
9-
#include "pycore_runtime.h"
10+
#include "pycore_runtime.h" // _Py_ID()
1011

11-
#include "pycore_importdl.h"
1212

1313
/* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is
1414
supported on this platform. configure will then compile and link in one

Python/marshal.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99
#include "Python.h"
1010
#include "pycore_call.h" // _PyObject_CallNoArgs()
1111
#include "pycore_code.h" // _PyCode_New()
12-
#include "pycore_critical_section.h" // Py_BEGIN_CRITICAL_SECTION()
1312
#include "pycore_hashtable.h" // _Py_hashtable_t
14-
#include "pycore_long.h" // _PyLong_DigitCount
15-
#include "pycore_setobject.h" // _PySet_NextEntry()
16-
#include "marshal.h" // Py_MARSHAL_VERSION
13+
#include "pycore_long.h" // _PyLong_IsZero()
1714
#include "pycore_pystate.h" // _PyInterpreterState_GET()
15+
#include "pycore_setobject.h" // _PySet_NextEntryRef()
16+
#include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal()
17+
18+
#include "marshal.h" // Py_MARSHAL_VERSION
1819

1920
#ifdef __APPLE__
2021
# include "TargetConditionals.h"
2122
#endif /* __APPLE__ */
2223

24+
2325
/*[clinic input]
2426
module marshal
2527
[clinic start generated code]*/

Python/perf_jit_trampoline.c

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "pycore_ceval.h" // _PyPerf_Callbacks
33
#include "pycore_frame.h"
44
#include "pycore_interp.h"
5+
#include "pycore_runtime.h" // _PyRuntime
56

67

78
#ifdef PY_HAVE_PERF_TRAMPOLINE

Python/perf_trampoline.c

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ any DWARF information available for them).
133133
#include "pycore_ceval.h" // _PyPerf_Callbacks
134134
#include "pycore_frame.h"
135135
#include "pycore_interp.h"
136+
#include "pycore_runtime.h" // _PyRuntime
136137

137138

138139
#ifdef PY_HAVE_PERF_TRAMPOLINE

Python/qsbr.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3333
*/
3434
#include "Python.h"
35-
#include "pycore_initconfig.h" // _PyStatus_NO_MEMORY()
36-
#include "pycore_lock.h" // PyMutex_Lock()
37-
#include "pycore_qsbr.h"
35+
#include "pycore_interp.h" // PyInterpreterState
3836
#include "pycore_pystate.h" // _PyThreadState_GET()
37+
#include "pycore_qsbr.h"
38+
#include "pycore_tstate.h" // _PyThreadStateImpl
3939

4040

4141
// Starting size of the array of qsbr thread states

Python/symtable.c

+5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
#include "pycore_ast.h" // stmt_ty
33
#include "pycore_parser.h" // _PyParser_ASTFromString()
44
#include "pycore_pystate.h" // _PyThreadState_GET()
5+
#include "pycore_runtime.h" // _Py_ID()
56
#include "pycore_symtable.h" // PySTEntryObject
7+
#include "pycore_unicodeobject.h" // _PyUnicode_EqualToASCIIString()
8+
9+
#include <stddef.h> // offsetof()
10+
611

712
// Set this to 1 to dump all symtables to stdout for debugging
813
#define _PY_DUMP_SYMTABLE 0

Python/thread.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#include "Python.h"
99
#include "pycore_ceval.h" // _PyEval_MakePendingCalls()
1010
#include "pycore_pystate.h" // _PyInterpreterState_GET()
11-
#include "pycore_structseq.h" // _PyStructSequence_FiniBuiltin()
1211
#include "pycore_pythread.h" // _POSIX_THREADS
12+
#include "pycore_runtime.h" // _PyRuntime
13+
#include "pycore_structseq.h" // _PyStructSequence_FiniBuiltin()
1314

1415
#ifndef DONT_HAVE_STDIO_H
1516
# include <stdio.h>

0 commit comments

Comments
 (0)