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

This commit is contained in:
Zackery Spytz 2020-11-16 14:32:35 -07:00 committed by GitHub
parent c26d5916d6
commit f62dad16b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

@ -0,0 +1,2 @@
The Windows launcher now properly handles Python 3.10 when listing installed
Python versions.

View File

@ -425,11 +425,21 @@ compare_pythons(const void * p1, const void * p2)
INSTALLED_PYTHON * ip1 = (INSTALLED_PYTHON *) p1; INSTALLED_PYTHON * ip1 = (INSTALLED_PYTHON *) p1;
INSTALLED_PYTHON * ip2 = (INSTALLED_PYTHON *) p2; INSTALLED_PYTHON * ip2 = (INSTALLED_PYTHON *) p2;
/* note reverse sorting on version */ /* note reverse sorting on version */
int result = wcscmp(ip2->version, ip1->version); int result = CompareStringW(LOCALE_INVARIANT, SORT_DIGITSASNUMBERS,
ip2->version, -1, ip1->version, -1);
if (result == 0) switch (result) {
result = ip2->bits - ip1->bits; /* 64 before 32 */ case 0:
return result; 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 static void