https://github.com/python/cpython/commit/d6375c3d2e9d24919e438c1e17ae86add4ec2725
commit: d6375c3d2e9d24919e438c1e17ae86add4ec2725
branch: 3.14
author: Chris Eibl <[email protected]>
committer: zware <[email protected]>
date: 2026-09-15T18:52:59-05:00
summary:

[3.14] gh-157368: Fix clang-cl version in sys.version on Windows (GH-157569)

Co-authored-by: Stan Ulbrych <[email protected]>
(cherry picked from commit 0ba7be9a18e8b03af1c046d676f71be9208e06d4)

files:
A Misc/NEWS.d/next/Windows/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst
M PC/pyconfig.h

diff --git 
a/Misc/NEWS.d/next/Windows/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst 
b/Misc/NEWS.d/next/Windows/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst
new file mode 100644
index 000000000000000..72e11bfe2b15384
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst
@@ -0,0 +1,3 @@
+Fix truncated :data:`sys.version` in the case of clang-cl versions 22 or newer
+on Windows. Also fixes the Windows on Arm case, where the Microsoft
+compiler was reported instead of clang. Patch by Chris Eibl.
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index 710a737ebcc0819..bb0c89651ab4dc4 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -143,17 +143,24 @@ WIN32 is still required for the locale module.
 #define MS_WIN64
 #endif
 
+#ifdef __clang__
+#define _Py_CLANG_COMPILER(platform) ( \
+   "[Clang " _Py_STRINGIZE(__clang_major__) "." _Py_STRINGIZE(__clang_minor__) 
\
+   "." _Py_STRINGIZE(__clang_patchlevel__) " " platform \
+   " with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
+#endif
+
 /* set the COMPILER and support tier
  *
  * win_amd64 MSVC (x86_64-pc-windows-msvc): 1
  * win32 MSVC (i686-pc-windows-msvc): 1
  * win_arm64 MSVC (aarch64-pc-windows-msvc): 3
- * other archs and ICC: 0
+ * other archs and clang-cl/ICC: 0
  */
 #ifdef MS_WIN64
 #if defined(_M_X64) || defined(_M_AMD64)
 #if defined(__clang__)
-#define COMPILER ("[Clang " __clang_version__ "] 64 bit (AMD64) with MSC v." 
_Py_STRINGIZE(_MSC_VER) " CRT]")
+#define COMPILER _Py_CLANG_COMPILER("64 bit (AMD64)")
 #define PY_SUPPORT_TIER 0
 #elif defined(__INTEL_COMPILER)
 #define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) 
with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
@@ -164,8 +171,13 @@ WIN32 is still required for the locale module.
 #endif /* __clang__ */
 #define PYD_PLATFORM_TAG "win_amd64"
 #elif defined(_M_ARM64)
+#if defined(__clang__)
+#define COMPILER _Py_CLANG_COMPILER("64 bit (ARM64)")
+#define PY_SUPPORT_TIER 0
+#else
 #define COMPILER _Py_PASTE_VERSION("64 bit (ARM64)")
 #define PY_SUPPORT_TIER 3
+#endif /* __clang__ */
 #define PYD_PLATFORM_TAG "win_arm64"
 #else
 #define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
@@ -215,7 +227,7 @@ typedef _W64 int Py_ssize_t;
 #if defined(MS_WIN32) && !defined(MS_WIN64)
 #if defined(_M_IX86)
 #if defined(__clang__)
-#define COMPILER ("[Clang " __clang_version__ "] 32 bit (Intel) with MSC v." 
_Py_STRINGIZE(_MSC_VER) " CRT]")
+#define COMPILER _Py_CLANG_COMPILER("32 bit (Intel)")
 #define PY_SUPPORT_TIER 0
 #elif defined(__INTEL_COMPILER)
 #define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) 
with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")

_______________________________________________
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