https://github.com/python/cpython/commit/3f226c5a7f776997b8bec4c7009b07c7bc93da94
commit: 3f226c5a7f776997b8bec4c7009b07c7bc93da94
branch: 3.12
author: Victor Stinner <vstin...@python.org>
committer: vstinner <vstin...@python.org>
date: 2025-03-11T11:55:13Z
summary:

[3.12] gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (#131044) (#131085)

gh-131082: Add missing guards for WIN32_LEAN_AND_MEAN (#131044)

(cherry picked from commit de8818ae233b8e7722aa5d6f91d4b5a04bd039df)

Co-authored-by: Max Bachmann <kont...@maxbachmann.de>

files:
M Include/internal/pycore_condvar.h
M Modules/_io/winconsoleio.c
M Python/sysmodule.c

diff --git a/Include/internal/pycore_condvar.h 
b/Include/internal/pycore_condvar.h
index 981c962bf7dfdf..2177bed31fcd27 100644
--- a/Include/internal/pycore_condvar.h
+++ b/Include/internal/pycore_condvar.h
@@ -37,8 +37,10 @@
 #define Py_HAVE_CONDVAR
 
 /* include windows if it hasn't been done before */
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#ifndef WIN32_LEAN_AND_MEAN
+#  define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>              // CRITICAL_SECTION
 
 /* options */
 /* non-emulated condition variables are provided for those that want
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c
index da4907ec2db2a8..164789ef218524 100644
--- a/Modules/_io/winconsoleio.c
+++ b/Modules/_io/winconsoleio.c
@@ -23,7 +23,7 @@
 #include <stddef.h> /* For offsetof */
 
 #ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
+#  define WIN32_LEAN_AND_MEAN
 #endif
 #include <windows.h>
 #include <fcntl.h>
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index e3bdff15a856bf..6ed28ec5fbd8ba 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -39,8 +39,10 @@ Data members:
 #include <locale.h>
 
 #ifdef MS_WINDOWS
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  include <windows.h>
 #endif /* MS_WINDOWS */
 
 #ifdef MS_COREDLL

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to