[Python-checkins] bpo-38506: Fix the Windows py.exe launcher's misordering of 3.10 (GH-18307)

zooba webhook-mailer at python.org
Mon Nov 16 16:32:46 EST 2020


https://github.com/python/cpython/commit/f62dad16b8e540486a0a0fed41e723d36986f860
commit: f62dad16b8e540486a0a0fed41e723d36986f860
branch: master
author: Zackery Spytz <zspytz at gmail.com>
committer: zooba <steve.dower at microsoft.com>
date: 2020-11-16T21:32:35Z
summary:

bpo-38506: Fix the Windows py.exe launcher's misordering of 3.10 (GH-18307)

files:
A Misc/NEWS.d/next/Windows/2020-11-15-23-01-14.bpo-38506.hhdnuP.rst
M PC/launcher.c

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 0000000000000..8ad75ef5ea093
--- /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 7ca2f2387801c..cc2d35b2c4cb7 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



More information about the Python-checkins mailing list