Skip to content

gh-145410: Fix sysconfig.get_platform() on Windows when sys.version is truncated#145635

Open
04cb wants to merge 1 commit intopython:mainfrom
04cb:fix/sysconfig-platform-truncation
Open

gh-145410: Fix sysconfig.get_platform() on Windows when sys.version is truncated#145635
04cb wants to merge 1 commit intopython:mainfrom
04cb:fix/sysconfig-platform-truncation

Conversation

@04cb
Copy link

@04cb 04cb commented Mar 8, 2026

Fixes #145410

The function was checking for 'amd64' in sys.version to detect 64-bit
Windows, but sys.version is truncated at a fixed width and may not
contain the architecture marker when the compiler version string is long.

Use platform.machine() instead, which reliably returns the machine
architecture on Windows regardless of the sys.version content.

The function was checking for 'amd64' in sys.version to detect 64-bit
Windows, but sys.version is truncated at a fixed width and may not
contain the architecture marker when the compiler version string is long.

Use platform.machine() instead, which reliably returns the machine
architecture on Windows regardless of the sys.version content.

Fixes python#145410
@04cb 04cb requested a review from FFY00 as a code owner March 8, 2026 06:36
@bedevere-app
Copy link

bedevere-app bot commented Mar 8, 2026

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@python-cla-bot
Copy link

python-cla-bot bot commented Mar 8, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@StanFromIreland StanFromIreland changed the title Fix sysconfig.get_platform() on Windows when sys.version is truncated gh-145410: Fix sysconfig.get_platform() on Windows when sys.version is truncated Mar 8, 2026
@chris-eibl
Copy link
Member

Quoting @zooba from the issue #145410 (comment)

sysconfig should rely on _sysconfig if it needs access to something known at compile time.

I also don't think this is the way to go. Furthermore, CI hints that there are problems to solve ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sysconfig.get_platform() could return wrong value because sys.version is truncated

2 participants