From 62183b8d6d49e59c6a98bbdaa65b7ea1415abb7f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 15 Apr 2020 02:04:42 +0200 Subject: [PATCH] bpo-40268: Remove explicit pythread.h includes (#19529) Remove explicit pythread.h includes: it is always included by Python.h. --- Include/Python.h | 1 + Include/pystate.h | 2 -- Modules/_blake2/blake2b_impl.c | 1 - Modules/_blake2/blake2s_impl.c | 1 - Modules/_bz2module.c | 2 -- Modules/_decimal/_decimal.c | 1 - Modules/_io/bufferedio.c | 1 - Modules/_lzmamodule.c | 1 - Modules/_queuemodule.c | 1 - Modules/_sqlite/connection.c | 2 -- Modules/_ssl.c | 2 -- Modules/_testcapimodule.c | 1 - Modules/_threadmodule.c | 1 - Modules/_tkinter.c | 2 -- Modules/_tracemalloc.c | 1 - Modules/faulthandler.c | 1 - Modules/posixmodule.c | 1 - Modules/signalmodule.c | 2 -- Modules/socketmodule.c | 7 +------ Modules/timemodule.c | 11 +++++------ Modules/zlibmodule.c | 1 - Parser/myreadline.c | 1 - Programs/_testembed.c | 1 - Python/ceval.c | 1 - Python/import.c | 2 -- Python/pylifecycle.c | 2 -- Python/sysmodule.c | 1 - Python/thread.c | 2 -- 28 files changed, 7 insertions(+), 46 deletions(-) diff --git a/Include/Python.h b/Include/Python.h index 769ec49779c..7fdb9df7065 100644 --- a/Include/Python.h +++ b/Include/Python.h @@ -131,6 +131,7 @@ #include "pyerrors.h" #include "cpython/initconfig.h" +#include "pythread.h" #include "pystate.h" #include "context.h" diff --git a/Include/pystate.h b/Include/pystate.h index c46d3fef15d..65b0a24e87f 100644 --- a/Include/pystate.h +++ b/Include/pystate.h @@ -7,8 +7,6 @@ extern "C" { #endif -#include "pythread.h" - /* This limitation is for performance and simplicity. If needed it can be removed (with effort). */ #define MAX_CO_EXTRA_USERS 255 diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c index 88c103f56c4..7fb1296f8b2 100644 --- a/Modules/_blake2/blake2b_impl.c +++ b/Modules/_blake2/blake2b_impl.c @@ -15,7 +15,6 @@ #include "Python.h" #include "pystrhex.h" -#include "pythread.h" #include "../hashlib.h" #include "blake2ns.h" diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c index c7c7eafdee2..e3e90d0587b 100644 --- a/Modules/_blake2/blake2s_impl.c +++ b/Modules/_blake2/blake2s_impl.c @@ -15,7 +15,6 @@ #include "Python.h" #include "pystrhex.h" -#include "pythread.h" #include "../hashlib.h" #include "blake2ns.h" diff --git a/Modules/_bz2module.c b/Modules/_bz2module.c index 008aef0555f..d46f96cc866 100644 --- a/Modules/_bz2module.c +++ b/Modules/_bz2module.c @@ -5,8 +5,6 @@ #include "Python.h" #include "structmember.h" -#include "pythread.h" - #include #include diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c index cdc942f2158..99f12364ad8 100644 --- a/Modules/_decimal/_decimal.c +++ b/Modules/_decimal/_decimal.c @@ -28,7 +28,6 @@ #include #include "longintrepr.h" -#include "pythread.h" #include "structmember.h" #include "complexobject.h" #include "mpdecimal.h" diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 4ec42eb0108..f243ac84e9e 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -11,7 +11,6 @@ #include "Python.h" #include "pycore_object.h" #include "structmember.h" -#include "pythread.h" #include "_iomodule.h" /*[clinic input] diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c index 714458be783..eac36b2d72f 100644 --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -9,7 +9,6 @@ #include "Python.h" #include "structmember.h" -#include "pythread.h" #include #include diff --git a/Modules/_queuemodule.c b/Modules/_queuemodule.c index 28bf8991285..062102e5c81 100644 --- a/Modules/_queuemodule.c +++ b/Modules/_queuemodule.c @@ -1,6 +1,5 @@ #include "Python.h" #include "structmember.h" /* offsetof */ -#include "pythread.h" /*[clinic input] module _queue diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 91041b95cd8..87a9f410213 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -30,8 +30,6 @@ #include "prepare_protocol.h" #include "util.h" -#include "pythread.h" - #define ACTION_FINALIZE 1 #define ACTION_RESET 2 diff --git a/Modules/_ssl.c b/Modules/_ssl.c index a471a26e933..d633a06053a 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -18,8 +18,6 @@ #include "Python.h" -#include "pythread.h" - /* Redefined below for Windows debug builds after important #includes */ #define _PySSL_FIX_ERRNO diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index c97cbe83551..8a76a3b1f24 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -17,7 +17,6 @@ #include "Python.h" #include "datetime.h" #include "marshal.h" -#include "pythread.h" #include "structmember.h" #include #include diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 8ff06698a80..6e7ee0f43e3 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -6,7 +6,6 @@ #include "pycore_pylifecycle.h" #include "pycore_interp.h" // _PyInterpreterState.num_threads #include "pycore_pystate.h" // _PyThreadState_Init() -#include "pythread.h" #include // offsetof() static PyObject *ThreadError; diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 199ae4f0db8..f530c5b0eb7 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -26,8 +26,6 @@ Copyright (C) 1994 Steen Lumholt. #include "Python.h" #include -#include "pythread.h" - #ifdef MS_WINDOWS #include #endif diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index 6f3f31a67b5..691de07b9b3 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -4,7 +4,6 @@ #include "pycore_traceback.h" #include "hashtable.h" #include "frameobject.h" -#include "pythread.h" #include "osdefs.h" #include "clinic/_tracemalloc.c.h" diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index ec9debcd948..e7a28503305 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -1,7 +1,6 @@ #include "Python.h" #include "pycore_initconfig.h" #include "pycore_traceback.h" -#include "pythread.h" #include #include #include diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 692dda314b3..7ac74842152 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -38,7 +38,6 @@ #include "pycore_ceval.h" /* _PyEval_ReInitThreads() */ #include "pycore_import.h" /* _PyImport_ReInitLock() */ #include "pycore_pystate.h" /* _PyInterpreterState_GET() */ -#include "pythread.h" #include "structmember.h" #ifndef MS_WINDOWS # include "posixmodule.h" diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c index 69d69ace28e..8348971c353 100644 --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -104,8 +104,6 @@ class sigset_t_converter(CConverter): may not be the thread that received the signal. */ -#include "pythread.h" - static volatile struct { _Py_atomic_int tripped; PyObject *func; diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 722c06e372e..2be0c103f80 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -234,13 +234,8 @@ http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/net/getaddrinfo.c.diff?r1=1.82& #define RELEASE_GETADDRINFO_LOCK #endif -#if defined(USE_GETHOSTBYNAME_LOCK) || defined(USE_GETADDRINFO_LOCK) -# include "pythread.h" -#endif - - #if defined(__APPLE__) || defined(__CYGWIN__) || defined(__NetBSD__) -# include +# include #endif diff --git a/Modules/timemodule.c b/Modules/timemodule.c index e269cd047fb..a0e66ac170b 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -25,13 +25,12 @@ #endif #if defined(__WATCOMC__) && !defined(__QNX__) -#include +# include #else -#ifdef MS_WINDOWS -#define WIN32_LEAN_AND_MEAN -#include -#include "pythread.h" -#endif /* MS_WINDOWS */ +# ifdef MS_WINDOWS +# define WIN32_LEAN_AND_MEAN +# include +# endif /* MS_WINDOWS */ #endif /* !__WATCOMC__ || __QNX__ */ #ifdef _Py_MEMORY_SANITIZER diff --git a/Modules/zlibmodule.c b/Modules/zlibmodule.c index 49d231a4baa..c2900a1243f 100644 --- a/Modules/zlibmodule.c +++ b/Modules/zlibmodule.c @@ -10,7 +10,6 @@ #include "zlib.h" -#include "pythread.h" #define ENTER_ZLIB(obj) \ Py_BEGIN_ALLOW_THREADS; \ PyThread_acquire_lock((obj)->lock, 1); \ diff --git a/Parser/myreadline.c b/Parser/myreadline.c index 7da8ea83780..04c2793225c 100644 --- a/Parser/myreadline.c +++ b/Parser/myreadline.c @@ -19,7 +19,6 @@ PyThreadState* _PyOS_ReadlineTState = NULL; -#include "pythread.h" static PyThread_type_lock _PyOS_ReadlineLock = NULL; int (*PyOS_InputHook)(void) = NULL; diff --git a/Programs/_testembed.c b/Programs/_testembed.c index da3e7861d1e..249f7e2304f 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -9,7 +9,6 @@ #include "pycore_initconfig.h" // _PyConfig_InitCompatConfig() #include "pycore_runtime.h" // _PyRuntime #include -#include "pythread.h" #include #include #include diff --git a/Python/ceval.c b/Python/ceval.c index 505f05cadd1..5e543567193 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -240,7 +240,6 @@ UNSIGNAL_ASYNC_EXC(PyInterpreterState *interp) #ifdef HAVE_ERRNO_H #include #endif -#include "pythread.h" #include "ceval_gil.h" static void diff --git a/Python/import.c b/Python/import.c index 49334637d67..2f2e9d17061 100644 --- a/Python/import.c +++ b/Python/import.c @@ -150,8 +150,6 @@ _PyImportZip_Init(PyThreadState *tstate) in different threads to return with a partially loaded module. These calls are serialized by the global interpreter lock. */ -#include "pythread.h" - static PyThread_type_lock import_lock = 0; static unsigned long import_lock_thread = PYTHREAD_INVALID_THREAD_ID; static int import_lock_level = 0; diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 754e7620a0c..974b425712c 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -2350,8 +2350,6 @@ Py_ExitStatusException(PyStatus status) /* Clean up and exit */ -# include "pythread.h" - /* For the atexit module. */ void _Py_PyAtExit(void (*func)(PyObject *), PyObject *module) { diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 741979a09ac..63111d58ab2 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -26,7 +26,6 @@ Data members: #include "pycore_pymem.h" #include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_tupleobject.h" -#include "pythread.h" #include "pydtrace.h" #include "osdefs.h" diff --git a/Python/thread.c b/Python/thread.c index 12761031866..a10f5728dc0 100644 --- a/Python/thread.c +++ b/Python/thread.c @@ -23,8 +23,6 @@ #include -#include "pythread.h" - #ifndef _POSIX_THREADS /* Check if we're running on HP-UX and _SC_THREADS is defined. If so, then