Skip to content

Commit 978e37b

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

23 files changed

+80
-45
lines changed

Modules/_io/_iomodule.c

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 5 additions & 3 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 5 additions & 2 deletions
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

Lines changed: 6 additions & 5 deletions
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

Lines changed: 6 additions & 4 deletions
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

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)