Synced docs and docstring for sysconfig.get_platform (#135530)

Co-authored-by: Mikhail Efimov <efimov.mikhail@gmail.com>
Co-authored-by: Ned Deily <nad@python.org>
This commit is contained in:
ivan 2025-09-16 08:16:48 -03:00 committed by GitHub
parent b9dbf6acb3
commit 01cc53295c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 18 deletions

View file

@ -382,22 +382,19 @@ Other functions
Examples of returned values: Examples of returned values:
- linux-i586
- linux-alpha (?)
- solaris-2.6-sun4u
Windows will return one of: Windows:
- win-amd64 (64-bit Windows on AMD64, aka x86_64, Intel64, and EM64T) - win-amd64 (64-bit Windows on AMD64, aka x86_64, Intel64, and EM64T)
- win-arm64 (64-bit Windows on ARM64, aka AArch64) - win-arm64 (64-bit Windows on ARM64, aka AArch64)
- win32 (all others - specifically, sys.platform is returned) - win32 (all others - specifically, sys.platform is returned)
macOS can return: POSIX based OS:
- macosx-10.6-ppc - linux-x86_64
- macosx-10.4-ppc64 - macosx-15.5-arm64
- macosx-10.3-i386 - macosx-26.0-universal2 (macOS on Apple Silicon or Intel)
- macosx-10.4-fat - android-24-arm64_v8a
For other non-POSIX platforms, currently just returns :data:`sys.platform`. For other non-POSIX platforms, currently just returns :data:`sys.platform`.

View file

@ -645,18 +645,22 @@ def get_platform():
isn't particularly important. isn't particularly important.
Examples of returned values: Examples of returned values:
linux-i586
linux-alpha (?)
solaris-2.6-sun4u
Windows will return one of:
win-amd64 (64-bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc)
win-arm64 (64-bit Windows on ARM64 (aka AArch64)
win32 (all others - specifically, sys.platform is returned)
For other non-POSIX platforms, currently just returns 'sys.platform'. Windows:
""" - win-amd64 (64-bit Windows on AMD64, aka x86_64, Intel64, and EM64T)
- win-arm64 (64-bit Windows on ARM64, aka AArch64)
- win32 (all others - specifically, sys.platform is returned)
POSIX based OS:
- linux-x86_64
- macosx-15.5-arm64
- macosx-26.0-universal2 (macOS on Apple Silicon or Intel)
- android-24-arm64_v8a
For other non-POSIX platforms, currently just returns :data:`sys.platform`."""
if os.name == 'nt': if os.name == 'nt':
if 'amd64' in sys.version.lower(): if 'amd64' in sys.version.lower():
return 'win-amd64' return 'win-amd64'

View file

@ -352,6 +352,13 @@ def test_get_platform(self):
self.assertEqual(get_platform(), 'macosx-10.4-%s' % arch) self.assertEqual(get_platform(), 'macosx-10.4-%s' % arch)
for macver in range(11, 16):
_osx_support._remove_original_values(get_config_vars())
get_config_vars()['CFLAGS'] = ('-fno-strict-overflow -Wsign-compare -Wunreachable-code'
'-arch arm64 -fno-common -dynamic -DNDEBUG -g -O3 -Wall')
get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = f"{macver}.0"
self.assertEqual(get_platform(), 'macosx-%d.0-arm64' % macver)
# linux debian sarge # linux debian sarge
os.name = 'posix' os.name = 'posix'
sys.version = ('2.3.5 (#1, Jul 4 2007, 17:28:59) ' sys.version = ('2.3.5 (#1, Jul 4 2007, 17:28:59) '