René's URL Explorer Experiment


Title: test_importlib.test_windows: vendored `get_platform()` misdetects clang-cl builds as `win32`, failing `test_tagged_suffix` · Issue #154200 · python/cpython · GitHub

Open Graph Title: test_importlib.test_windows: vendored `get_platform()` misdetects clang-cl builds as `win32`, failing `test_tagged_suffix` · Issue #154200 · python/cpython

X Title: test_importlib.test_windows: vendored `get_platform()` misdetects clang-cl builds as `win32`, failing `test_tagged_suffix` · Issue #154200 · python/cpython

Description: Bug description: test_tagged_suffix in Lib/test/test_importlib/test_windows.py fails on Windows CPython built with clang-cl (build.bat "/p:PlatformToolset=ClangCL", documented in PCbuild/readme.txt; see the reproduction note below about ...

Open Graph Description: Bug description: test_tagged_suffix in Lib/test/test_importlib/test_windows.py fails on Windows CPython built with clang-cl (build.bat "/p:PlatformToolset=ClangCL", documented in PCbuild/readme.txt...

X Description: Bug description: test_tagged_suffix in Lib/test/test_importlib/test_windows.py fails on Windows CPython built with clang-cl (build.bat "/p:PlatformToolset=ClangCL", documented in PCbuild/...

Opengraph URL: https://github.com/python/cpython/issues/154200

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_importlib.test_windows: vendored `get_platform()` misdetects clang-cl builds as `win32`, failing `test_tagged_suffix`","articleBody":"### Bug description:\n\n`test_tagged_suffix` in `Lib/test/test_importlib/test_windows.py` fails on Windows CPython built with clang-cl (`build.bat \"/p:PlatformToolset=ClangCL\"`, documented in PCbuild/readme.txt; see the reproduction note below about `VSCMD_ARG_TGT_ARCH`). The root cause is the same `sys.version`-truncation misdetection that gh-145410 fixed for `sysconfig.get_platform()` in March 2026 (by moving the check into the `_sysconfig.get_platform()` C accelerator, GH-146145) — but this test computes its expected suffix with a vendored \"[Port of distutils.util.get_platform()](https://github.com/python/cpython/blob/16d0c89b875c520cf5af9da5ba4db133358f742f/Lib/test/test_importlib/test_windows.py#L20-L37)\" that still carries the pre-fix logic: it sniffs `sys.version.lower()` for `'amd64'`, misses on the truncated clang banner, and falls through to `return sys.platform` → `'win32'`.\n\n```\n$ python -m unittest -v test.test_importlib.test_windows -k tagged\ntest_tagged_suffix (test.test_importlib.test_windows.Frozen_WindowsExtensionSuffixTests.test_tagged_suffix) ... FAIL\ntest_tagged_suffix (test.test_importlib.test_windows.Source_WindowsExtensionSuffixTests.test_tagged_suffix) ... FAIL\n\n======================================================================\nFAIL: test_tagged_suffix (test.test_importlib.test_windows.Frozen_WindowsExtensionSuffixTests.test_tagged_suffix)\n----------------------------------------------------------------------\nTraceback (most recent call last):\n  File \"D:\\Python\\3.16t\\Lib\\test\\test_importlib\\test_windows.py\", line 154, in test_tagged_suffix\n    self.assertIn(expected_tag, suffixes)\n    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^\nAssertionError: '.cp316t-win32.pyd' not found in ['.cp316t-win_amd64.pyd', '.pyd']\n```\n\n(the `Source_` variant fails identically)\n\n**Reproduction note:** the vendored function checks `VSCMD_ARG_TGT_ARCH` first, so the failure only manifests *outside* a VS developer prompt (or with a non-matching target arch); inside `vcvars64` the env var masks it and the test passes. Run the repro from a plain shell.\n\nThe interpreter itself is right — the test's expectation is wrong:\n\n```pycon\n>>> import sys, sysconfig\n>>> sys.version\n'3.16.0a0 free-threading build (heads/ft-opt-dirty:2f032556f42, Jul 16 2026, 11:20:12) [Clang 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174d'\n>>> sysconfig.get_platform()   # fixed by gh-145410\n'win-amd64'\n>>> from test.test_importlib.test_windows import get_platform; get_platform()   # vendored copy, pre-fix logic\n'win32'\n>>> import importlib.machinery; importlib.machinery.EXTENSION_SUFFIXES\n['.cp316t-win_amd64.pyd', '.pyd']\n```\n\n`EXTENSION_SUFFIXES` is built from `PYD_PLATFORM_TAG` in `PC/pyconfig.h` and is correct; only the test's vendored helper is stale.\n\n**Why the banner sniff misses on clang-cl builds:** [`PC/pyconfig.h#L161`](https://github.com/python/cpython/blob/16d0c89b875c520cf5af9da5ba4db133358f742f/PC/pyconfig.h#L161) does put `\"] 64 bit (AMD64) with MSC v.NNNN CRT]\"` into the clang compiler banner — but [`Python/getversion.c#L18-L20`](https://github.com/python/cpython/blob/16d0c89b875c520cf5af9da5ba4db133358f742f/Python/getversion.c#L18-L20) caps the compiler segment of `sys.version` at `%.80s`, and official LLVM Windows binaries have an 86-char `__clang_version__` (version + URL + full 40-char commit hash — verified against the `llvmorg-22.1.8` tag commit `ca7933e4…`). With the 7-char `\"[Clang \"` prefix the 80-char cut always lands inside the hash, so the tail carrying `(AMD64)` is truncated away — note the banner above ends 28 characters into the commit hash, inside a never-closed parenthesis, with no `(AMD64)` and no closing bracket. An MSVC banner (`[MSC v.19NN 64 bit (AMD64)]`, ~27 chars) is never truncated, which is why this is clang-specific.\n\n**Prior art:** the same assertion tripped on an early free-threaded Windows buildbot (gh-110359, 2023: `'_d.cp313-win32.pyd' not found in ['_d.cp313t-win_amd64.pyd', '_d.pyd']`). That report's `win32` came from the builder's VS target-arch environment rather than from banner truncation — an MSVC compiler segment is far too short to truncate — but it is the same expected-tag computation going wrong. Only the abi-flag half was addressed there (gh-109740; GH-110422 for gh-110119); the vendored platform sniff was left untouched, and it is what now bites clang-cl builds. Free-threading isn't part of the mechanism either — only the `abi_flags` term of the expected tag depends on it, so a non-FT clang-cl build should fail identically with `.cp316-win32.pyd` vs `.cp316-win_amd64.pyd` (I've only run free-threaded builds myself).\n\n**Suggested fix** (deferring to the maintainers): replace the [`get_platform()` call at L146](https://github.com/python/cpython/blob/16d0c89b875c520cf5af9da5ba4db133358f742f/Lib/test/test_importlib/test_windows.py#L146) with `sysconfig.get_platform()` and delete the vendored function (that call is its only consumer). This does not make the test circular: `SYSCONFIG_PLATFORM` in `Modules/_sysconfig.c` and `PYD_PLATFORM_TAG` in `PC/pyconfig.h` are independent definitions in separate files, so the test still cross-checks two separate code paths. I'm happy to submit a PR — the change is small and test-only.\n\n**Environment / build:** built from `2f032556f42` = local branch `ft-opt` merged with CPython main @ f62050d6574 (2026-07-16), per PCbuild with `build.bat -p x64 --disable-gil --pgo --tail-call-interp \"/p:PlatformToolset=ClangCL\"`, LLVM 22.1.8 official Windows release, Windows 11 x64; also reproduced on an earlier (June 2026) clang-cl build. All cited code verified unchanged on main as of 2026-07-19; permalinks sha-pinned to 16d0c89b875. My branch carries only build-system tuning (PCbuild props/vcxproj plus a zlib-ng header) and build-regenerated files (hence the `-dirty` banner); `Lib/test/test_importlib/test_windows.py`, `Python/getversion.c`, and `PC/pyconfig.h` are unmodified from upstream.\n\nclang-cl is `PY_SUPPORT_TIER 0`, but PCbuild documents the toolset and it is actively kept working (gh-77532; e.g. gh-146210 in 2026, gh-131278/gh-130090/gh-131035 in 2025) — and the failing logic is a test bug, not a platform gap.\n\nThe same 80-char banner truncation also breaks `ctypes.util.find_msvcrt()`'s `\"MSC v.\"` sniff, causing a `test_ctypes.test_errno` failure; filed separately as gh-154199.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-154210\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/SynaptSea","@type":"Person","name":"SynaptSea"},"datePublished":"2026-07-19T20:52:13Z","url":"https://github.com/python/cpython/issues/154200"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8eb1e01d-4c1f-2ffc-53f9-fdc2b1e9f8e5
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCCB0:2C4BED:38A3C20:47F49ED:6B01F406
html-safe-nonceac4cff11eb13f552b6c076ac944b8dfe22047fae03c31a85e4a62385fb429a19
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0IwOjJDNEJFRDozOEEzQzIwOjQ3RjQ5RUQ6NkIwMUY0MDYiLCJ2aXNpdG9yX2lkIjoiMTc1MTY1NzI0NjU3MDU0NzI2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac23ed27975b8c7c61312e1f59f683242b970db801c413ef8a12ab69bdae7e7eef
hovercard-subject-tagissue:4924346138
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/154200/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b6652a7ecd593e544a1b271f126e26f988aa7953b0aaa466e42b20c9f90ca356/python/cpython/issues/154200
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b6652a7ecd593e544a1b271f126e26f988aa7953b0aaa466e42b20c9f90ca356/python/cpython/issues/154200
og:image:altBug description: test_tagged_suffix in Lib/test/test_importlib/test_windows.py fails on Windows CPython built with clang-cl (build.bat "/p:PlatformToolset=ClangCL", documented in PCbuild/readme.txt...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameSynaptSea
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/154200#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F154200
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F154200
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/154200
Reloadhttps://github.com/python/cpython/issues/154200
Reloadhttps://github.com/python/cpython/issues/154200
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/154200
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/154200
#154210https://github.com/python/cpython/pull/154210
test_importlib.test_windows: vendored get_platform() misdetects clang-cl builds as win32, failing test_tagged_suffixhttps://github.com/python/cpython/issues/154200#top
#154210https://github.com/python/cpython/pull/154210
OS-unsupportedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-unsupported%22
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/SynaptSea
SynaptSeahttps://github.com/SynaptSea
on Jul 19, 2026https://github.com/python/cpython/issues/154200#issue-4924346138
gh-145410https://github.com/python/cpython/issues/145410
GH-146145https://github.com/python/cpython/pull/146145
Port of distutils.util.get_platform()https://github.com/python/cpython/blob/16d0c89b875c520cf5af9da5ba4db133358f742f/Lib/test/test_importlib/test_windows.py#L20-L37
PC/pyconfig.h#L161https://github.com/python/cpython/blob/16d0c89b875c520cf5af9da5ba4db133358f742f/PC/pyconfig.h#L161
Python/getversion.c#L18-L20https://github.com/python/cpython/blob/16d0c89b875c520cf5af9da5ba4db133358f742f/Python/getversion.c#L18-L20
gh-110359https://github.com/python/cpython/issues/110359
gh-109740https://github.com/python/cpython/issues/109740
GH-110422https://github.com/python/cpython/pull/110422
gh-110119https://github.com/python/cpython/issues/110119
get_platform() call at L146https://github.com/python/cpython/blob/16d0c89b875c520cf5af9da5ba4db133358f742f/Lib/test/test_importlib/test_windows.py#L146
f62050dhttps://github.com/python/cpython/commit/f62050d65743f0c895f7e6d665936c4e86aa39d5
16d0c89https://github.com/python/cpython/commit/16d0c89b875c520cf5af9da5ba4db133358f742f
gh-77532https://github.com/python/cpython/issues/77532
gh-146210https://github.com/python/cpython/issues/146210
gh-131278https://github.com/python/cpython/issues/131278
gh-130090https://github.com/python/cpython/issues/130090
gh-131035https://github.com/python/cpython/issues/131035
gh-154199https://github.com/python/cpython/issues/154199
gh-154200: Use sysconfig.get_platform() in test_importlib.test_windows #154210https://github.com/python/cpython/pull/154210
picnixzhttps://github.com/picnixz
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%22
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
on Jul 19, 2026https://github.com/python/cpython/issues/154200#event-28189189389
https://github.com/picnixz
picnixzhttps://github.com/picnixz
on Jul 19, 2026https://github.com/python/cpython/issues/154200#issuecomment-5017730952
@chris-eiblhttps://github.com/chris-eibl
encukouhttps://github.com/encukou
OS-unsupportedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-unsupported%22
on Jul 22, 2026https://github.com/python/cpython/issues/154200#event-28317419515
github-project-automationhttps://github.com/apps/github-project-automation
Unsupported platformshttps://github.com/orgs/python/projects/27
on Jul 22, 2026https://github.com/python/cpython/issues/154200#event-28317422108
chris-eiblhttps://github.com/chris-eibl
on Aug 29, 2026https://github.com/python/cpython/issues/154200#event-30214494876
gh-154200: Use sysconfig.get_platform() in test_importlib.test_windows (https://github.com/python/cpython/commit/5cb7c39e6378d6cfd2bca140aa1eebf72cc7ffd3
gh-154200https://github.com/python/cpython/issues/154200
5cb7c39https://github.com/python/cpython/commit/5cb7c39e6378d6cfd2bca140aa1eebf72cc7ffd3
chris-eiblhttps://github.com/chris-eibl
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#154210https://github.com/python/cpython/pull/154210
on Aug 29, 2026https://github.com/python/cpython/issues/154200#event-30214494957
github-project-automationhttps://github.com/apps/github-project-automation
Unsupported platformshttps://github.com/orgs/python/projects/27
on Aug 29, 2026https://github.com/python/cpython/issues/154200
clin1234https://github.com/clin1234
on Sep 12, 2026https://github.com/python/cpython/issues/154200#event-31023911269
pythongh-154200: Use sysconfig.get_platform() in test_importlib.test_…https://github.com/clin1234/cpython/commit/aa9cbd2518bc9c280f982a94bb62c66c6e917288
pythongh-154200https://github.com/python/cpython/issues/154200
aa9cbd2https://github.com/clin1234/cpython/commit/aa9cbd2518bc9c280f982a94bb62c66c6e917288
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/154200
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/154200
OS-unsupportedhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-unsupported%22
OS-windowshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-windows%22
testsTests in the Lib/test dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22tests%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
Unsupported platformshttps://github.com/orgs/python/projects/27
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.