GeezerVison is showing github.com — Fix clang-cl version in sys.version on Windows · Issue #157368 · python/cpython
Fix clang-cl version in sys.version on Windows #157368Labels OS-unsupportedOS-windowsinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug report
Bug description:
Since version 22, clang-cl on Windows includes the repo url and commit hash in __clang_version__ like
22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
versus just 21.1.4. before.
This results in sys.version being truncated
__clang_version__ is used in
|
#define _Py_COMPILER ("[Clang " __clang_version__ "] 64 bit (AMD64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]") |
exposed via getcompiler.c and then truncated in
|
#ifdef Py_GIL_DISABLED |
|
const char *buildinfo_format = "%.80s free-threading build (%.80s) %.80s"; |
|
#else |
|
const char *buildinfo_format = "%.80s (%.80s) %.80s"; |
|
#endif |
|
PyOS_snprintf(version, sizeof(version), buildinfo_format, |
|
PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler()); |
3.16.0a0 (heads/main:7bfa97f4dc, Sep 12 2026, 16:30:16) [Clang 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb45022 on win32
versus
3.16.0a0 (heads/main:7bfa97f4dc, Sep 12 2026, 16:32:39) [Clang 21.1.4 ] 64 bit (AMD64) with MSC v.1951 CRT] on win32
A lot of code depends on being able to parse the now missing 64 bit (AMD64) part (#145410, #154200, #154199, ...). Let's restore the old behaviour and fix the stray ] as well:
3.16.0a0 (heads/fix_clang_version:e1b196dfab, Sep 12 2026, 16:28:42) [Clang 22.1.3 64 bit (AMD64) with MSC v.1951 CRT] on win32
This also fixes the failing test_single_line_statement of @zware's AMD64 Windows Server 2025 Clang 3.x buildbot (and would also fix all the failing tests of the 3.14 and 3.15 Windows clang buildbots).
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Linked PRs
ActivityStanFromIreland commented on Sep 12, 2026 JYFI, if you're planning to fix this yourself I suggest you assign yourself, otherwise agents have a habit of sending PRs for such things... chris-eibl commented on Sep 12, 2026 Reacted by Stan Ulbrych and An Long chris-eibl commented on Sep 12, 2026 StanFromIreland commented on Sep 12, 2026 Aargh, sorry, that makes sense! zware commented on Sep 15, 2026 Done other than 3.15, which I think will probably wait for 3.15.0 final. Reacted by Chris Eibl Reacted by Chris Eibl vstinner commented on Oct 2, 2026 I wrote PR gh-158608 to allocate Py_GetVersion() on the heap memory, to no longer have fixed limits.
MetadataMetadataOS-unsupportedOS-windowsinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error StatusShow more project fields
DevelopmentNo branches or pull requestsIssue actions
|