diff options
author | Zackery Spytz <zspytz@gmail.com> | 2020-11-16 21:32:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 21:32:35 (GMT) |
commit | f62dad16b8e540486a0a0fed41e723d36986f860 (patch) | |
tree | abad391ff3c7a899db0d90236855bc968fe313af | |
parent | c26d5916d68c47a20dd941f9e89afdaf85b2711e (diff) | |
download | cpython-f62dad16b8e540486a0a0fed41e723d36986f860.zip cpython-f62dad16b8e540486a0a0fed41e723d36986f860.tar.gz cpython-f62dad16b8e540486a0a0fed41e723d36986f860.tar.bz2 |
bpo-38506: Fix the Windows py.exe launcher's misordering of 3.10 (GH-18307)
-rw-r--r-- | Misc/NEWS.d/next/Windows/2020-11-15-23-01-14.bpo-38506.hhdnuP.rst | 2 | ||||
-rw-r--r-- | PC/launcher.c | 20 |
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 |