diff --git a/Lib/sysconfig/__init__.py b/Lib/sysconfig/__init__.py index 8ff9c99435bb1a..1f780bc8f44ec0 100644 --- a/Lib/sysconfig/__init__.py +++ b/Lib/sysconfig/__init__.py @@ -665,12 +665,17 @@ def get_platform(): For other non-POSIX platforms, currently just returns :data:`sys.platform`.""" if os.name == 'nt': + # Check for architecture in sys.version first, then fall back to sys.maxsize + # which is reliable even when sys.version is truncated (e.g., clang builds on Windows) if 'amd64' in sys.version.lower(): return 'win-amd64' - if '(arm)' in sys.version.lower(): - return 'win-arm32' + if sys.maxsize > 2**32: + # 64-bit Windows where sys.version may be truncated + return 'win-amd64' if '(arm64)' in sys.version.lower(): return 'win-arm64' + if '(arm)' in sys.version.lower(): + return 'win-arm32' return sys.platform if os.name != "posix" or not hasattr(os, 'uname'): diff --git a/Lib/uuid.py b/Lib/uuid.py index c0150a59d7cb9a..44ab127933876e 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -951,6 +951,13 @@ def main(): "@x500": NAMESPACE_X500 } + def _namespace_type(value): + if value in namespaces: + return value + # Validate it's a valid UUID string + UUID(value) + return value + import argparse parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, @@ -962,7 +969,8 @@ def main(): default="uuid4", help="function to generate the UUID") parser.add_argument("-n", "--namespace", - choices=["any UUID", *namespaces.keys()], + type=_namespace_type, + metavar='{any UUID,@dns,@url,@oid,@x500}', help="uuid3/uuid5 only: " "a UUID, or a well-known predefined UUID addressed " "by namespace name")