From 03c4080c71f49df9c219354b7b38b738917fd2ed Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 3 Sep 2023 18:54:27 +0200 Subject: gh-108765: Python.h no longer includes (#108831) Remove in C files which don't use it; only sre.c and _decimal.c still use it. Remove _PY_PORT_CTYPE_UTF8_ISSUE code from pyport.h: * Code added by commit b5047fd01948ab108edcc1b3c2c901d915814cfd in 2004 for MacOSX and FreeBSD. * Test removed by commit 52ddaefb6bab1a74ecffe8519c02735794ebfbe1 in 2007, since Python str type now uses locale independent functions like Py_ISALPHA() and Py_TOLOWER() and the Unicode database. Modules/_sre/sre.c replaces _PY_PORT_CTYPE_UTF8_ISSUE with new functions: sre_isalnum(), sre_tolower(), sre_toupper(). Remove unused includes: * _localemodule.c: remove . * getargs.c: remove . * dynload_win.c: remove , it no longer calls _getcwd() since commit fb1f68ed7cc1536482d1debd70a53c5442135fe2 (in 2001). --- Python/bltinmodule.c | 1 - Python/ceval.c | 4 +--- Python/codecs.c | 1 - Python/dynload_win.c | 9 ++------- Python/errors.c | 1 - Python/getargs.c | 4 ---- Python/mystrtoul.c | 14 ++++++++++---- 7 files changed, 13 insertions(+), 21 deletions(-) (limited to 'Python') diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 971067e2d4f..8e234e085f1 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1,7 +1,6 @@ /* Built-in functions */ #include "Python.h" -#include #include "pycore_ast.h" // _PyAST_Validate() #include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_ceval.h" // _PyEval_Vector() diff --git a/Python/ceval.c b/Python/ceval.c index a22852ec13e..6f90d8e6fd0 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -35,9 +35,7 @@ #include "pydtrace.h" #include "setobject.h" - -#include -#include +#include // bool #ifdef Py_DEBUG /* For debugging the interpreter: */ diff --git a/Python/codecs.c b/Python/codecs.c index 87ae896b8e7..b79bf555f2f 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -14,7 +14,6 @@ Copyright (c) Corporation for National Research Initiatives. #include "pycore_pyerrors.h" // _PyErr_FormatNote() #include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI -#include const char *Py_hexdigits = "0123456789abcdef"; diff --git a/Python/dynload_win.c b/Python/dynload_win.c index acab05e2c6d..f69995b8f9e 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -5,13 +5,8 @@ #include "pycore_fileutils.h" // _Py_add_relfile() #include "pycore_pystate.h" // _PyInterpreterState_GET() -#ifdef HAVE_DIRECT_H -#include -#endif -#include - -#include "importdl.h" -#include "patchlevel.h" +#include "importdl.h" // dl_funcptr +#include "patchlevel.h" // PY_MAJOR_VERSION #include #ifdef _DEBUG diff --git a/Python/errors.c b/Python/errors.c index fb5b3ff2c7b..f670b78c1f1 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -10,7 +10,6 @@ #include "pycore_sysmodule.h" // _PySys_Audit() #include "pycore_traceback.h" // _PyTraceBack_FromFrame() -#include #ifdef MS_WINDOWS # include # include diff --git a/Python/getargs.c b/Python/getargs.c index fdc144488c9..cbfe5611111 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -7,10 +7,6 @@ #include "pycore_pylifecycle.h" // _PyArg_Fini #include "pycore_tuple.h" // _PyTuple_ITEMS() -#include -#include - - #ifdef __cplusplus extern "C" { #endif diff --git a/Python/mystrtoul.c b/Python/mystrtoul.c index e6fe154eed6..fcd3e27f17f 100644 --- a/Python/mystrtoul.c +++ b/Python/mystrtoul.c @@ -1,16 +1,22 @@ +// strtol() and strtoul(), renamed to avoid conflicts. +// +// API: +// +// - PyOS_strtol(): convert string to C long integer. +// - PyOS_strtoul(): convert string to C unsigned long integer. + #include "Python.h" #include "pycore_long.h" // _PyLong_DigitValue #if defined(__sgi) && !defined(_SGI_MP_SOURCE) -#define _SGI_MP_SOURCE +# define _SGI_MP_SOURCE #endif /* strtol and strtoul, renamed to avoid conflicts */ -#include #ifdef HAVE_ERRNO_H -#include +# include // errno #endif /* Static overflow check values for bases 2 through 36. @@ -75,7 +81,7 @@ static const int digitlimit[] = { 14, 14, 14, 14, 13, 13, 13, 13, 13, 13, /* 20 - 29 */ 13, 12, 12, 12, 12, 12, 12}; /* 30 - 36 */ #else -#error "Need table for SIZEOF_LONG" +# error "Need table for SIZEOF_LONG" #endif /* -- cgit v1.2.3