Skip to content

Commit

Permalink
bpo-45616: Let py.exe distinguish between v3.1 and v3.10 (GH-29731)
Browse files Browse the repository at this point in the history
  • Loading branch information
zware authored Nov 24, 2021
1 parent 9cf5646 commit f9de97a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix Python Launcher's ability to distinguish between versions 3.1 and 3.10
when either one is explicitly requested. Previously, 3.1 would be used if
3.10 was requested but not installed, and 3.10 would be used if 3.1 was
requested but 3.10 was installed.
11 changes: 10 additions & 1 deletion PC/launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,17 @@ find_python_by_version(wchar_t const * wanted_ver)
}
for (i = 0; i < num_installed_pythons; i++, ip++) {
n = wcslen(ip->version);
if (n > wlen)
/*
* If wlen is greater than 1, we're probably trying to find a specific
* version and thus want an exact match: 3.1 != 3.10. Otherwise, we
* just want a prefix match.
*/
if ((wlen > 1) && (n != wlen)) {
continue;
}
if (n > wlen) {
n = wlen;
}
if ((wcsncmp(ip->version, wanted_ver, n) == 0) &&
/* bits == 0 => don't care */
((bits == 0) || (ip->bits == bits))) {
Expand Down

0 comments on commit f9de97a

Please sign in to comment.