Skip to content

Commit f3592ae

Browse files
author
RoomWithOutRoof
committed
Fix sysconfig.get_platform() for truncated sys.version on Windows
On Windows, sysconfig.get_platform() checks for 'amd64' in sys.version to detect 64-bit builds. However, sys.version can be truncated (e.g., ~100 chars on clang builds), causing 'amd64' to be missing and returning 'win32' incorrectly. This fix adds sys.maxsize > 2**32 as a fallback check, which is reliable even when sys.version is truncated. Also reorders arm64 check before arm32 for proper precedence. Fixes: #145410
1 parent 656abe3 commit f3592ae

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

Lib/sysconfig/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,17 @@ def get_platform():
665665
666666
For other non-POSIX platforms, currently just returns :data:`sys.platform`."""
667667
if os.name == 'nt':
668+
# Check for architecture in sys.version first, then fall back to sys.maxsize
669+
# which is reliable even when sys.version is truncated (e.g., clang builds on Windows)
668670
if 'amd64' in sys.version.lower():
669671
return 'win-amd64'
670-
if '(arm)' in sys.version.lower():
671-
return 'win-arm32'
672+
if sys.maxsize > 2**32:
673+
# 64-bit Windows where sys.version may be truncated
674+
return 'win-amd64'
672675
if '(arm64)' in sys.version.lower():
673676
return 'win-arm64'
677+
if '(arm)' in sys.version.lower():
678+
return 'win-arm32'
674679
return sys.platform
675680

676681
if os.name != "posix" or not hasattr(os, 'uname'):

0 commit comments

Comments
 (0)