Skip to content

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

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

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
Copy Markdown

@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 #145410
@04cb 04cb requested a review from FFY00 as a code owner March 8, 2026 06:36
@bedevere-app
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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 ...

Copy link
Copy Markdown
Member

@zooba zooba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the way - platform and sysconfig have different purposes, so they shouldn't mix.

Add a compile-time constant to _sysconfig for this.

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Mar 9, 2026

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@04cb 04cb closed this by deleting the head repository Mar 10, 2026
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

3 participants