https://github.com/python/cpython/commit/d207c7cd5a8c0d3e5f6c5eb947243e4afcd718b0
commit: d207c7cd5a8c0d3e5f6c5eb947243e4afcd718b0
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2024-02-20T16:50:43Z
summary:

gh-110850: Cleanup pycore_time.h includes (#115724)

<pycore_time.h> include is no longer needed to get the PyTime_t type
in internal header files. This type is now provided by <Python.h>
include. Add <pycore_time.h> includes to C files instead.

files:
M Include/internal/pycore_import.h
M Include/internal/pycore_lock.h
M Include/internal/pycore_parking_lot.h
M Include/internal/pycore_semaphore.h
M Modules/_datetimemodule.c
M Modules/_lsprof.c
M Modules/_randommodule.c
M Modules/_ssl.c
M Modules/_testinternalcapi/test_lock.c
M Modules/_threadmodule.c
M Modules/faulthandler.c
M Modules/posixmodule.c
M Modules/signalmodule.c
M Modules/socketmodule.c
M Modules/socketmodule.h
M Modules/timemodule.c
M Python/gc.c
M Python/gc_free_threading.c
M Python/import.c
M Python/lock.c
M Python/parking_lot.c
M Python/thread_nt.h
M Python/thread_pthread.h

diff --git a/Include/internal/pycore_import.h b/Include/internal/pycore_import.h
index 5f49b9aa6dfebf..eb8a9a0db46c22 100644
--- a/Include/internal/pycore_import.h
+++ b/Include/internal/pycore_import.h
@@ -11,7 +11,6 @@ extern "C" {
 
 #include "pycore_lock.h"          // PyMutex
 #include "pycore_hashtable.h"     // _Py_hashtable_t
-#include "pycore_time.h"          // PyTime_t
 
 extern int _PyImport_IsInitialized(PyInterpreterState *);
 
diff --git a/Include/internal/pycore_lock.h b/Include/internal/pycore_lock.h
index 1aaa6677932282..07bf3db16f3d3a 100644
--- a/Include/internal/pycore_lock.h
+++ b/Include/internal/pycore_lock.h
@@ -13,8 +13,6 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-#include "pycore_time.h"          // PyTime_t
-
 
 // A mutex that occupies one byte. The lock can be zero initialized.
 //
diff --git a/Include/internal/pycore_parking_lot.h 
b/Include/internal/pycore_parking_lot.h
index a192228970c6a3..8c9260e2636fbc 100644
--- a/Include/internal/pycore_parking_lot.h
+++ b/Include/internal/pycore_parking_lot.h
@@ -18,8 +18,6 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-#include "pycore_time.h"        // PyTime_t
-
 
 enum {
     // The thread was unparked by another thread.
diff --git a/Include/internal/pycore_semaphore.h 
b/Include/internal/pycore_semaphore.h
index e1963a6ea239e1..ffcc6d80344d6e 100644
--- a/Include/internal/pycore_semaphore.h
+++ b/Include/internal/pycore_semaphore.h
@@ -8,7 +8,6 @@
 #endif
 
 #include "pycore_pythread.h"      // _POSIX_SEMAPHORES
-#include "pycore_time.h"          // PyTime_t
 
 #ifdef MS_WINDOWS
 #   define WIN32_LEAN_AND_MEAN
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index b8bd70250aee29..3ae95a8c9a87a7 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -14,6 +14,8 @@
 #include "Python.h"
 #include "pycore_long.h"          // _PyLong_GetOne()
 #include "pycore_object.h"        // _PyObject_Init()
+#include "pycore_time.h"          // _PyTime_ObjectToTime_t()
+
 #include "datetime.h"
 
 
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index eae4261f4953f5..928baf034f62a3 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -6,6 +6,7 @@
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
 #include "pycore_ceval.h"         // _PyEval_SetProfile()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_time.h"          // _PyTime_FromNanosecondsObject()
 
 #include "rotatingtree.h"
 
diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c
index 4463157d62248d..62f1acaf887296 100644
--- a/Modules/_randommodule.c
+++ b/Modules/_randommodule.c
@@ -75,6 +75,7 @@
 #include "pycore_modsupport.h"    // _PyArg_NoKeywords()
 #include "pycore_moduleobject.h"  // _PyModule_GetState()
 #include "pycore_pylifecycle.h"   // _PyOS_URandomNonblock()
+#include "pycore_time.h"          // _PyTime_GetSystemClock()
 
 #ifdef HAVE_UNISTD_H
 #  include <unistd.h>             // getpid()
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 1bf7241042d39a..d00f407b569fb6 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -28,6 +28,7 @@
 #include "Python.h"
 #include "pycore_fileutils.h"     // _PyIsSelectable_fd()
 #include "pycore_pyerrors.h"      // _PyErr_ChainExceptions1()
+#include "pycore_time.h"          // _PyDeadline_Init()
 #include "pycore_weakref.h"       // _PyWeakref_GET_REF()
 
 /* Include symbols from _socket module */
diff --git a/Modules/_testinternalcapi/test_lock.c 
b/Modules/_testinternalcapi/test_lock.c
index 9facbc5bccf9f9..724bbd0e8f0c9d 100644
--- a/Modules/_testinternalcapi/test_lock.c
+++ b/Modules/_testinternalcapi/test_lock.c
@@ -1,8 +1,9 @@
 // C Extension module to test pycore_lock.h API
 
 #include "parts.h"
-
 #include "pycore_lock.h"
+#include "pycore_time.h"          // _PyTime_GetMonotonicClock()
+
 #include "clinic/test_lock.c.h"
 
 #ifdef MS_WINDOWS
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 226053437bc2cd..addaafb4f86039 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -9,6 +9,7 @@
 #include "pycore_pylifecycle.h"
 #include "pycore_pystate.h"       // _PyThreadState_SetCurrent()
 #include "pycore_sysmodule.h"     // _PySys_GetAttr()
+#include "pycore_time.h"          // _PyTime_FromSeconds()
 #include "pycore_weakref.h"       // _PyWeakref_GET_REF()
 
 #include <stdbool.h>
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 91255fc98885ae..02e94a21191483 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -4,6 +4,7 @@
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_signal.h"        // Py_NSIG
 #include "pycore_sysmodule.h"     // _PySys_GetAttr()
+#include "pycore_time.h"          // _PyTime_FromSecondsObject()
 #include "pycore_traceback.h"     // _Py_DumpTracebackThreads
 
 #ifdef HAVE_UNISTD_H
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 4165fb66cc10dd..fd70b38bddec79 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -23,6 +23,7 @@
 #include "pycore_pylifecycle.h"   // _PyOS_URandom()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_signal.h"        // Py_NSIG
+#include "pycore_time.h"          // _PyLong_FromTime_t()
 
 #ifdef HAVE_UNISTD_H
 #  include <unistd.h>             // symlink()
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index a968cb1b0aa49c..5804e30af1b426 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -13,6 +13,7 @@
 #include "pycore_pyerrors.h"      // _PyErr_SetString()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_signal.h"        // _Py_RestoreSignals()
+#include "pycore_time.h"          // _PyTime_FromSecondsObject()
 
 #ifndef MS_WINDOWS
 #  include "posixmodule.h"        // _PyLong_FromUid()
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 9f70dbe4a83c2f..298c0e29d0d9b8 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -109,6 +109,7 @@ Local naming conventions:
 #include "pycore_capsule.h"       // _PyCapsule_SetTraverse()
 #include "pycore_fileutils.h"     // _Py_set_inheritable()
 #include "pycore_moduleobject.h"  // _PyModule_GetState
+#include "pycore_time.h"          // _PyTime_AsMilliseconds()
 
 #ifdef _Py_MEMORY_SANITIZER
 #  include <sanitizer/msan_interface.h>
diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h
index a7c592c83aa25f..09fd70f351f1d8 100644
--- a/Modules/socketmodule.h
+++ b/Modules/socketmodule.h
@@ -1,7 +1,5 @@
 /* Socket module header file */
 
-#include "pycore_time.h"          // PyTime_t
-
 /* Includes needed for the sockaddr_* symbols below */
 #ifndef MS_WINDOWS
 #ifdef __VMS
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 16769b2405f706..73b9fc067af6ff 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -5,6 +5,7 @@
 #include "pycore_moduleobject.h"  // _PyModule_GetState()
 #include "pycore_namespace.h"     // _PyNamespace_New()
 #include "pycore_runtime.h"       // _Py_ID()
+#include "pycore_time.h"          // _PyTimeFraction
 
 #include <time.h>                 // clock()
 #ifdef HAVE_SYS_TIMES_H
diff --git a/Python/gc.c b/Python/gc.c
index b665e4681b3c39..907f29baa3777a 100644
--- a/Python/gc.c
+++ b/Python/gc.c
@@ -12,6 +12,7 @@
 #include "pycore_object_alloc.h"  // _PyObject_MallocWithType()
 #include "pycore_pyerrors.h"
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_time.h"          // _PyTime_GetPerfCounter()
 #include "pycore_weakref.h"       // _PyWeakref_ClearRef()
 #include "pydtrace.h"
 
diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c
index 0f159f4a272be6..88c9c4ae5d77b9 100644
--- a/Python/gc_free_threading.c
+++ b/Python/gc_free_threading.c
@@ -11,6 +11,7 @@
 #include "pycore_object_stack.h"
 #include "pycore_pyerrors.h"
 #include "pycore_pystate.h"       // _PyThreadState_GET()
+#include "pycore_time.h"          // _PyTime_GetPerfCounter()
 #include "pycore_tstate.h"        // _PyThreadStateImpl
 #include "pycore_weakref.h"       // _PyWeakref_ClearRef()
 #include "pydtrace.h"
diff --git a/Python/import.c b/Python/import.c
index 6512963d9f6bed..a8fed67755256e 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -13,6 +13,7 @@
 #include "pycore_pymem.h"         // _PyMem_SetDefaultAllocator()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 #include "pycore_sysmodule.h"     // _PySys_Audit()
+#include "pycore_time.h"          // _PyTime_GetPerfCounter()
 #include "pycore_weakref.h"       // _PyWeakref_GET_REF()
 
 #include "marshal.h"              // PyMarshal_ReadObjectFromString()
diff --git a/Python/lock.c b/Python/lock.c
index 0c0d298f17d54f..a4b044ecff0d70 100644
--- a/Python/lock.c
+++ b/Python/lock.c
@@ -5,12 +5,13 @@
 #include "pycore_lock.h"
 #include "pycore_parking_lot.h"
 #include "pycore_semaphore.h"
+#include "pycore_time.h"          // _PyTime_GetMonotonicClock()
 
 #ifdef MS_WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>        // SwitchToThread()
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>        // SwitchToThread()
 #elif defined(HAVE_SCHED_H)
-#include <sched.h>          // sched_yield()
+#  include <sched.h>          // sched_yield()
 #endif
 
 // If a thread waits on a lock for longer than TIME_TO_BE_FAIR_NS (1 ms), then
diff --git a/Python/parking_lot.c b/Python/parking_lot.c
index 9a8a403a746914..9bf8376e485ea4 100644
--- a/Python/parking_lot.c
+++ b/Python/parking_lot.c
@@ -1,11 +1,12 @@
 #include "Python.h"
 
 #include "pycore_llist.h"
-#include "pycore_lock.h"        // _PyRawMutex
+#include "pycore_lock.h"          // _PyRawMutex
 #include "pycore_parking_lot.h"
-#include "pycore_pyerrors.h"    // _Py_FatalErrorFormat
-#include "pycore_pystate.h"     // _PyThreadState_GET
-#include "pycore_semaphore.h"   // _PySemaphore
+#include "pycore_pyerrors.h"      // _Py_FatalErrorFormat
+#include "pycore_pystate.h"       // _PyThreadState_GET
+#include "pycore_semaphore.h"     // _PySemaphore
+#include "pycore_time.h"          //_PyTime_GetMonotonicClock()
 
 #include <stdbool.h>
 
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
index 9ca2a55cae5eef..307352f592e70e 100644
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -1,4 +1,5 @@
-#include "pycore_interp.h"    // _PyInterpreterState.threads.stacksize
+#include "pycore_interp.h"        // _PyInterpreterState.threads.stacksize
+#include "pycore_time.h"          // _PyTime_AsMicroseconds()
 
 /* This code implemented by [email protected] */
 /* Fast NonRecursiveMutex support by Yakov Markovitch, [email protected] */
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
index ce0af736e8f7e4..9db6a4666f510c 100644
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -1,5 +1,6 @@
 #include "pycore_interp.h"        // _PyInterpreterState.threads.stacksize
 #include "pycore_pythread.h"      // _POSIX_SEMAPHORES
+#include "pycore_time.h"          // _PyTime_FromMicrosecondsClamup()
 
 /* Posix threads interface */
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to