https://github.com/python/cpython/commit/f9de97aae5fe9dafb58a8099171f4a09c449f4e8
commit: f9de97aae5fe9dafb58a8099171f4a09c449f4e8
branch: main
author: Zachary Ware <zach@python.org>
committer: zware <zachary.ware@gmail.com>
date: 2021-11-23T22:41:04-06:00
summary:
bpo-45616: Let py.exe distinguish between v3.1 and v3.10 (GH-29731)
files:
A Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
M PC/launcher.c
diff --git a/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst b/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
new file mode 100644
index 0000000000000..000f2fd3cc989
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
@@ -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.
diff --git a/PC/launcher.c b/PC/launcher.c
index fbfb49ae857ac..f8b8a3db39775 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))) {
_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins
commit: f9de97aae5fe9dafb58a8099171f4a09c449f4e8
branch: main
author: Zachary Ware <zach@python.org>
committer: zware <zachary.ware@gmail.com>
date: 2021-11-23T22:41:04-06:00
summary:
bpo-45616: Let py.exe distinguish between v3.1 and v3.10 (GH-29731)
files:
A Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
M PC/launcher.c
diff --git a/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst b/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
new file mode 100644
index 0000000000000..000f2fd3cc989
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2021-11-23-11-44-42.bpo-45616.K52PLZ.rst
@@ -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.
diff --git a/PC/launcher.c b/PC/launcher.c
index fbfb49ae857ac..f8b8a3db39775 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))) {
_______________________________________________
Python-checkins mailing list
Python-checkins@python.org
https://mail.python.org/mailman/listinfo/python-checkins