From 672a4f7b42847bcbaec3465e4460f710bbd2ec1b Mon Sep 17 00:00:00 2001 From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com> Date: Sat, 12 Sep 2026 19:16:52 +0200 Subject: [PATCH 1/4] fix clang compiler version in _Py_COMPILER --- ...6-09-12-18-59-21.gh-issue-157368.2DirHP.rst | 3 +++ PC/pyconfig.h | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst diff --git a/Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst b/Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst new file mode 100644 index 000000000000000..da0014f6de35fd9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst @@ -0,0 +1,3 @@ +Fix truncated :data:`sys.version` in case of clang-cl versions greater or +equal 22 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 982d4c662599a44..2dc1d5556a4fe72 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -148,17 +148,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 _Py_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): 2 - * 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 _Py_COMPILER ("[Clang " __clang_version__ "] 64 bit (AMD64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") +#define _Py_COMPILER _Py_CLANG_COMPILER("64 bit (AMD64)") #define PY_SUPPORT_TIER 0 #elif defined(__INTEL_COMPILER) #define _Py_COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") @@ -169,8 +176,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 _Py_COMPILER _Py_CLANG_COMPILER("64 bit (ARM64)") +#define PY_SUPPORT_TIER 0 +#else #define _Py_COMPILER _Py_PASTE_VERSION("64 bit (ARM64)") #define PY_SUPPORT_TIER 2 +#endif /* __clang__ */ #define PYD_PLATFORM_TAG "win_arm64" #else #define _Py_COMPILER _Py_PASTE_VERSION("64 bit (Unknown)") @@ -220,7 +232,7 @@ typedef _W64 int Py_ssize_t; #if defined(MS_WIN32) && !defined(MS_WIN64) #if defined(_M_IX86) #if defined(__clang__) -#define _Py_COMPILER ("[Clang " __clang_version__ "] 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") +#define _Py_COMPILER _Py_CLANG_COMPILER("32 bit (Intel)") #define PY_SUPPORT_TIER 0 #elif defined(__INTEL_COMPILER) #define _Py_COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") From 7cd5f4c532ad5e585c8355ab6f0977530920c6a3 Mon Sep 17 00:00:00 2001 From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:50:41 +0200 Subject: [PATCH 2/4] Update Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst Co-authored-by: Stan Ulbrych --- .../Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst b/Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst index da0014f6de35fd9..72e11bfe2b15384 100644 --- a/Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst +++ b/Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst @@ -1,3 +1,3 @@ -Fix truncated :data:`sys.version` in case of clang-cl versions greater or -equal 22 on Windows. Also fixes the Windows on Arm case, where the Microsoft +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. From a97eec8cd90fdfee3f2c48d8a390ffe1fecabdd5 Mon Sep 17 00:00:00 2001 From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com> Date: Sat, 12 Sep 2026 21:51:30 +0200 Subject: [PATCH 3/4] Update PC/pyconfig.h Co-authored-by: Stan Ulbrych --- PC/pyconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PC/pyconfig.h b/PC/pyconfig.h index 2dc1d5556a4fe72..5b1df0fc146c39d 100644 --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -150,7 +150,7 @@ WIN32 is still required for the locale module. #ifdef __clang__ #define _Py_CLANG_COMPILER(platform) ( \ - "[Clang " _Py_STRINGIZE(__clang_major__)"." _Py_STRINGIZE(__clang_minor__ ) \ + "[Clang " _Py_STRINGIZE(__clang_major__) "." _Py_STRINGIZE(__clang_minor__) \ "." _Py_STRINGIZE(__clang_patchlevel__) " " platform \ " with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") #endif From 91e94e58d893536c21f93a39c904eaaada0054dc Mon Sep 17 00:00:00 2001 From: Chris Eibl <138194463+chris-eibl@users.noreply.github.com> Date: Sun, 13 Sep 2026 07:48:08 +0200 Subject: [PATCH 4/4] move news to Windows --- .../2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Misc/NEWS.d/next/{Library => Windows}/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst (100%) diff --git a/Misc/NEWS.d/next/Library/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 similarity index 100% rename from Misc/NEWS.d/next/Library/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst rename to Misc/NEWS.d/next/Windows/2026-09-12-18-59-21.gh-issue-157368.2DirHP.rst