diff options
author | Zachary Ware <zach@python.org> | 2021-11-24 04:41:04 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 04:41:04 (GMT) |
commit | f9de97aae5fe9dafb58a8099171f4a09c449f4e8 (patch) | |
tree | 379fb2cdcaa176a78e5e1202672c53ce355dfe55 /PC | |
parent | 9cf5646bb465b7d3d68bfe6d4711feb43d565051 (diff) | |
download | cpython-f9de97aae5fe9dafb58a8099171f4a09c449f4e8.zip cpython-f9de97aae5fe9dafb58a8099171f4a09c449f4e8.tar.gz cpython-f9de97aae5fe9dafb58a8099171f4a09c449f4e8.tar.bz2 |
bpo-45616: Let py.exe distinguish between v3.1 and v3.10 (GH-29731)
Diffstat (limited to 'PC')
-rw-r--r-- | PC/launcher.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/PC/launcher.c b/PC/launcher.c index fbfb49a..f8b8a3d 100644 --- a/PC/launcher.c +++ b/PC/launcher.c @@ -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))) { |