gh-131238: Add explicit includes to pycore headers (#131257) · python/cpython@978e37b

GitHub

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

991010#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()

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()

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

Original file line numberDiff line numberDiff line change@@ -4,9 +4,10 @@

44#endif

5566#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

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()

9101011#include"datetime.h"// PyDateTime_TZInfo

11121213#include<stddef.h>// offsetof()

13-#include<stdint.h>

14+#include<stdint.h>// int64_t

15+14161517#include"clinic/_zoneinfo.c.h"

1618/*[clinic input]

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

303132+3133/* Sentinel to ignore all_threads on free-threading */

3234#defineFT_IGNORE_ALL_THREADS 2

3335Original 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()

6778#ifdefHAVE_UNISTD_H

89# include<unistd.h>// isatty()

910#endif

101112+1113#if defined(HAVE_GETC_UNLOCKED) && !defined(_Py_MEMORY_SANITIZER)

1214/* clang MemorySanitizer doesn't yet understand getc_unlocked. */

1315# defineGETC(f) getc_unlocked(f)

Original file line numberDiff line numberDiff line change@@ -1,9 +1,12 @@

11#include<Python.h>

2233#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+710811void*

912_PyPegen_dummy_name(Parser*p, ...)

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+2285228622862287 // Forward declaration

22872288 static int init_types(void *arg);

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

6778#ifdefHAVE_UNISTD_H

89# include<unistd.h>// lseek(), read()

@@ -13,6 +14,7 @@

1314#include"../lexer/lexer.h"

1415#include"../lexer/buffer.h"

151617+1618staticint

1719tok_concatenate_interactive_new_line(structtok_state*tok, constchar*line) {

1820assert(tok->fp_interactive);