summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS.d/next/Windows/2020-11-15-23-01-14.bpo-38506.hhdnuP.rst2
-rw-r--r--PC/launcher.c20
2 files changed, 17 insertions, 5 deletions
diff --git a/Misc/NEWS.d/next/Windows/2020-11-15-23-01-14.bpo-38506.hhdnuP.rst b/Misc/NEWS.d/next/Windows/2020-11-15-23-01-14.bpo-38506.hhdnuP.rst
new file mode 100644
index 0000000..8ad75ef
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2020-11-15-23-01-14.bpo-38506.hhdnuP.rst
@@ -0,0 +1,2 @@
+The Windows launcher now properly handles Python 3.10 when listing installed
+Python versions.
diff --git a/PC/launcher.c b/PC/launcher.c
index 7ca2f23..cc2d35b 100644
--- a/PC/launcher.c
+++ b/PC/launcher.c
@@ -425,11 +425,21 @@ compare_pythons(const void * p1, const void * p2)
INSTALLED_PYTHON * ip1 = (INSTALLED_PYTHON *) p1;
INSTALLED_PYTHON * ip2 = (INSTALLED_PYTHON *) p2;
/* note reverse sorting on version */
- int result = wcscmp(ip2->version, ip1->version);
-
- if (result == 0)
- result = ip2->bits - ip1->bits; /* 64 before 32 */
- return result;
+ int result = CompareStringW(LOCALE_INVARIANT, SORT_DIGITSASNUMBERS,
+ ip2->version, -1, ip1->version, -1);
+ switch (result) {
+ case 0:
+ error(0, L"CompareStringW failed");
+ return 0;
+ case CSTR_LESS_THAN:
+ return -1;
+ case CSTR_EQUAL:
+ return ip2->bits - ip1->bits; /* 64 before 32 */
+ case CSTR_GREATER_THAN:
+ return 1;
+ default:
+ return 0; // This should never be reached.
+ }
}
static void