GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-145410: Use _sysconfig.get_platform() in the platform module by vstinner · Pull Request #146148 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Mar 18, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: sysconfig.get_platform() could return wrong value because sys.version is truncated #145410

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
pythongh-146145: Use _sysconfig.get_platform() in the platform module
a43ceb0
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 18, 2026
@vstinner vstinner mentioned this pull request Mar 18, 2026
gh-145410: Add _sysconfig.get_platform() function #146145
Merged
@vstinner vstinner changed the title gh-146145: Use _sysconfig.get_platform() in the platform module gh-145410: Use _sysconfig.get_platform() in the platform module Mar 18, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Mar 18, 2026
sysconfig.get_platform() could return wrong value because sys.version is truncated #145410
Closed
@vstinner

vstinner commented Mar 18, 2026

Copy link
Copy Markdown
Member Author

The change avoids the WMI query (SELECT Architecture FROM Win32_Processor) in platform.machine() for these 4 sysconfig platforms: win32, win-amd64, win-arm32 and win-arm64.

cc @zooba

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner added 3 commits March 19, 2026 01:02
@vstinner
Fix _sysconfig_architecture for win-amd64
a97eafd
@vstinner
Add more tests on architecture()
35ebd34
@vstinner
Add even more tests on architecture()
ab70761
@vstinner vstinner mentioned this pull request Mar 19, 2026
extend sys module on windows #102536
Open
@vstinner

vstinner commented Mar 19, 2026

Copy link
Copy Markdown
Member Author

See also issues gh-102536 and gh-98962.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@malemburg

malemburg commented Mar 19, 2026

Copy link
Copy Markdown
Member

This looks fine, but can we be sure that the output does not change across supported Windows platforms ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Mar 19, 2026

Copy link
Copy Markdown
Member Author

According to #98962 (comment) comment, platform.architecture() is always ARM64, whereas sysconfig.get_platform() can be win-arm64, win-amd64 or win32 when Python is built for different architectures and run on ARM64 Windows. So it seems like platform.architecture() is not directly related to sysconfig.get_platform(), they can be different and my change is wrong.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Mar 19, 2026

Copy link
Copy Markdown
Member Author

cc @diegorusso

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

diegorusso
diegorusso approved these changes Mar 19, 2026
View reviewed changes

@diegorusso diegorusso left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I'm OK with the changes, just a minor comment on win-arm32 (that in my opinion we shouldn't need)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/platform.py
# platform: (arch, bits, linkage)
'win32': ('x86', '32bit', 'WindowsPE'),
'win-amd64': ('AMD64', '64bit', 'WindowsPE'),
'win-arm32': ('ARM', '32bit', 'WindowsPE'),

@diegorusso diegorusso Mar 19, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Do we really care about Windows on Arm 32bit? This is specifically Windows RT 8.1 which ended support in 2023.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@diegorusso diegorusso Mar 19, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

From https://learn.microsoft.com/en-us/windows/arm/arm32-to-arm64

Windows devices running on an Arm processor (...) no longer support AArch32 (Arm32). This change impacts Universal Windows Platform apps that presently target AArch32 (Arm32). Support for 32-bit Arm versions of applications is removed in a future release of Windows 11.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@zooba zooba Mar 20, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Until all support is entirely ripped out, it's still possible for someone to compile it. So we don't need it, but if someone out there needs it, we may as well leave it in until we're actively trying to prevent them doing their job (which, as a general rule, we don't do).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

diegorusso reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 19, 2026
diegorusso
diegorusso reviewed Mar 19, 2026
View reviewed changes

@diegorusso diegorusso left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Actually while we are here, we should update the documentation as well (if it is found to be inconsistent)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@malemburg

malemburg commented Mar 19, 2026

Copy link
Copy Markdown
Member

According to #98962 (comment) comment, platform.architecture() is always ARM64, whereas sysconfig.get_platform() can be win-arm64, win-amd64 or win32 when Python is built for different architectures and run on ARM64 Windows. So it seems like platform.architecture() is not directly related to sysconfig.get_platform(), they can be different and my change is wrong.

The platform module is meant for inspecting the platform Python runs on, sysconfig normally refers to the platform and settings it was compiled with.

As for return values, "win-arm64" is not an architecture. The "win-" part refers to the OS.

zooba reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

diegorusso
diegorusso requested changes Mar 19, 2026
View reviewed changes

@diegorusso diegorusso left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I've just realised that I approved the PR but I didn't mean to :)
I'm not sure If I can un-approve it, hence requesting a change.

My comments still stand.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 19, 2026
@bedevere-app

bedevere-app Bot commented Mar 19, 2026

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting changes label Mar 19, 2026
zooba
zooba requested changes Mar 20, 2026
View reviewed changes
Comment thread Lib/platform.py
Comment on lines +819 to +822
# Use _sysconfig.get_platform() if available
arch, bits, linkage = _sysconfig_platform()
if arch:
return arch

@zooba zooba Mar 20, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We can't do this, because the current CPU can be different from the Python runtime. We have to query the OS specifically, we can't rely on compile-time.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/platform.py

if not fileout and \
executable == sys.executable:
if not fileout and executable == sys.executable:

@zooba zooba Mar 20, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is the necessary condition for using _sysconfig.get_platform() - no change required, just pointing out why it's okay to assume that sys.executable is us.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner

vstinner commented Mar 20, 2026

Copy link
Copy Markdown
Member Author

We can't do this, because the current CPU can be different from the Python runtime. We have to query the OS specifically, we can't rely on compile-time.

Yeah, I understood that when reading #98962 after I wrote my PR. I prefer to close my PR, since it would return the wrong platform in some cases.

zooba reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner closed this Mar 20, 2026
@vstinner
vstinner deleted the platform_sysconfig branch March 20, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@zooba zooba zooba requested changes
@diegorusso diegorusso diegorusso requested changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting changes

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@vstinner @malemburg @diegorusso @zooba
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.