Skip to content

Commit f62dad1

Browse files
authored
bpo-38506: Fix the Windows py.exe launcher's misordering of 3.10 (GH-18307)
1 parent c26d591 commit f62dad1

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The Windows launcher now properly handles Python 3.10 when listing installed
2+
Python versions.

PC/launcher.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,21 @@ compare_pythons(const void * p1, const void * p2)
425425
INSTALLED_PYTHON * ip1 = (INSTALLED_PYTHON *) p1;
426426
INSTALLED_PYTHON * ip2 = (INSTALLED_PYTHON *) p2;
427427
/* note reverse sorting on version */
428-
int result = wcscmp(ip2->version, ip1->version);
429-
430-
if (result == 0)
431-
result = ip2->bits - ip1->bits; /* 64 before 32 */
432-
return result;
428+
int result = CompareStringW(LOCALE_INVARIANT, SORT_DIGITSASNUMBERS,
429+
ip2->version, -1, ip1->version, -1);
430+
switch (result) {
431+
case 0:
432+
error(0, L"CompareStringW failed");
433+
return 0;
434+
case CSTR_LESS_THAN:
435+
return -1;
436+
case CSTR_EQUAL:
437+
return ip2->bits - ip1->bits; /* 64 before 32 */
438+
case CSTR_GREATER_THAN:
439+
return 1;
440+
default:
441+
return 0; // This should never be reached.
442+
}
433443
}
434444

435445
static void

0 commit comments

Comments
 (0)