Repository navigation
Fix clang-cl version in sys.version on Windows #157368
Copy link
Copy link
Closed
Labels
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
Description
Bug 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
Line 161 in 7bfa97f
| #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
Lines 17 to 23 in 7bfa97f
| #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
- gh-157368: Fix clang-cl version in sys.version on Windows #157369
- [3.15] gh-157368: Fix clang-cl version in sys.version on Windows (GH-157369) #157565
- [3.14] gh-157368: Fix clang-cl version in sys.version on Windows (GH-157369) #157569
- [3.13] gh-157368: Fix clang-cl version in sys.version on Windows (GH-157369) #157606
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
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
Projects
- StatusShow more project fieldsDone
Activity
StanFromIreland commentedon 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 commentedon Sep 12, 2026
Hope I was faster :)
chris-eibl commentedon Sep 12, 2026
Adding
OS-unsupportedagain since @encukou ask me to do so for clang-cl issues in #154210 (comment).StanFromIreland commentedon Sep 12, 2026
Aargh, sorry, that makes sense!
gh-157368: Fix clang-cl version in sys.version on Windows (GH-157369)
pythongh-157368: Fix clang-cl version in sys.version on Windows (pyth…
[3.14] gh-157368: Fix clang-cl version in sys.version on Windows (GH-…
zware commentedon Sep 15, 2026
Done other than 3.15, which I think will probably wait for 3.15.0 final.
[3.15] gh-157368: Fix clang-cl version in sys.version on Windows (GH-…
vstinner commentedon Oct 2, 2026
I wrote PR gh-158608 to allocate Py_GetVersion() on the heap memory, to no longer have fixed limits.