From 7fd0ce2b0860093c3dd30e430419c838298b54ad Mon Sep 17 00:00:00 2001 From: Martin Boisvert Date: Wed, 18 Jan 2023 12:52:27 -0500 Subject: [PATCH 01/10] GH-101135: Add backwards compatibility for 2.x and 3.4 and lower For 32-bit installs, these versions did not contain the "-32" in their registry name, so the 32 and 64-bit installs were treated equal. Additionally, the code to replace a node with one with a lower sort key was buggy (wrong node chosen, replace never happened since parent was always NULL, replaced node never freed, etc) --- PC/launcher2.c | 68 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/PC/launcher2.c b/PC/launcher2.c index 8371c6014cd922..727f9e09432d7f 100644 --- a/PC/launcher2.c +++ b/PC/launcher2.c @@ -1294,34 +1294,65 @@ _compareTag(const wchar_t *x, const wchar_t *y) int -addEnvironmentInfo(EnvironmentInfo **root, EnvironmentInfo *node) +_compareArch(const wchar_t *x, const wchar_t *y) +{ + if (!x && !y) { + return 0; + } else if (!x) { + return -1; + } else if (!y) { + return 1; + } + + bool is64X = 0 == _compare(x, -1, L"64bit", -1); + bool is64Y = 0 == _compare(y, -1, L"64bit", -1); + if (is64X) { + return is64Y ? 0 : -1; + } else if (is64Y) { + return 1; + } + return _compare(x, -1, y, -1); +} + + +int +addEnvironmentInfo(EnvironmentInfo **root, EnvironmentInfo* parent, EnvironmentInfo *node) { EnvironmentInfo *r = *root; if (!r) { *root = node; - node->parent = NULL; + node->parent = parent; return 0; } // Sort by company name switch (_compareCompany(node->company, r->company)) { case -1: - return addEnvironmentInfo(&r->prev, node); + return addEnvironmentInfo(&r->prev, r, node); case 1: - return addEnvironmentInfo(&r->next, node); + return addEnvironmentInfo(&r->next, r, node); case 0: break; } // Then by tag (descending) switch (_compareTag(node->tag, r->tag)) { case -1: - return addEnvironmentInfo(&r->next, node); + return addEnvironmentInfo(&r->next, r, node); + case 1: + return addEnvironmentInfo(&r->prev, r, node); + case 0: + break; + } + // Then by architecture + switch (_compareArch(node->architecture, r->architecture)) { + case -1: + return addEnvironmentInfo(&r->prev, r, node); case 1: - return addEnvironmentInfo(&r->prev, node); + return addEnvironmentInfo(&r->next, r, node); case 0: break; } // Then keep the one with the lowest internal sort key - if (r->internalSortKey < node->internalSortKey) { + if (node->internalSortKey < r->internalSortKey) { // Replace the current node node->parent = r->parent; if (node->parent) { @@ -1334,9 +1365,16 @@ addEnvironmentInfo(EnvironmentInfo **root, EnvironmentInfo *node) freeEnvironmentInfo(node); return RC_INTERNAL_ERROR; } + } else { + // If node has no parent, then it is the root. + *root = node; } + node->next = r->next; node->prev = r->prev; + + debug(L"# replaced %s/%s/%i in tree\n", node->company, node->tag, node->internalSortKey); + freeEnvironmentInfo(r); } else { debug(L"# not adding %s/%s/%i to tree\n", node->company, node->tag, node->internalSortKey); return RC_DUPLICATE_ITEM; @@ -1486,7 +1524,7 @@ _registrySearchTags(const SearchInfo *search, EnvironmentInfo **result, HKEY roo freeEnvironmentInfo(env); exitCode = 0; } else if (!exitCode) { - exitCode = addEnvironmentInfo(result, env); + exitCode = addEnvironmentInfo(result, NULL, env); if (exitCode) { freeEnvironmentInfo(env); if (exitCode == RC_DUPLICATE_ITEM) { @@ -1574,7 +1612,7 @@ appxSearch(const SearchInfo *search, EnvironmentInfo **result, const wchar_t *pa copyWstr(&env->displayName, buffer); } - int exitCode = addEnvironmentInfo(result, env); + int exitCode = addEnvironmentInfo(result, NULL, env); if (exitCode) { freeEnvironmentInfo(env); if (exitCode == RC_DUPLICATE_ITEM) { @@ -1612,7 +1650,7 @@ explicitOverrideSearch(const SearchInfo *search, EnvironmentInfo **result) if (exitCode) { goto abort; } - exitCode = addEnvironmentInfo(result, env); + exitCode = addEnvironmentInfo(result, NULL, env); if (exitCode) { goto abort; } @@ -1661,7 +1699,7 @@ virtualenvSearch(const SearchInfo *search, EnvironmentInfo **result) if (exitCode) { goto abort; } - exitCode = addEnvironmentInfo(result, env); + exitCode = addEnvironmentInfo(result, NULL, env); if (exitCode) { goto abort; } @@ -2116,6 +2154,14 @@ _listAllEnvironments(EnvironmentInfo *env, FILE * out, bool showPath, Environmen buffer[0] = L'\0'; } else if (0 == _compare(env->company, -1, L"PythonCore", -1)) { swprintf_s(buffer, bufferSize, L"-V:%s", env->tag); + + // append "-32" to PythonCore 32-bit environments if it isn't already specified in the tag name + if (0 == _compare(env->architecture, -1, L"32bit", -1)) { + int tagLength = wcslen(env->tag); + if (tagLength <= 3 || 0 != _compare(&env->tag[tagLength - 3], 3, L"-32", 3)) { + wcscat_s(buffer, bufferSize, L"-32"); + } + } } else { swprintf_s(buffer, bufferSize, L"-V:%s/%s", env->company, env->tag); } From 86f1c837de95a00e9c84b0fac4c7edfb958a3763 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 18 Jan 2023 18:25:19 +0000 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20b?= =?UTF-8?q?lurb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst diff --git a/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst b/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst new file mode 100644 index 00000000000000..0ad5f97103e2f9 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst @@ -0,0 +1 @@ +Windows py launcher: fix backwards compatibility for older 32-bit versions From b28d7f9320c62399a8029c693041182b241447db Mon Sep 17 00:00:00 2001 From: Martin Boisvert Date: Wed, 18 Jan 2023 13:45:28 -0500 Subject: [PATCH 03/10] Reword blurb --- .../Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst b/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst index 0ad5f97103e2f9..419f47a511fb53 100644 --- a/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst +++ b/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst @@ -1 +1,3 @@ -Windows py launcher: fix backwards compatibility for older 32-bit versions +Restore ability to launch older 32-bit versions from the :file:`py.exe` +launcher when both 32-bit and 64-bit installs of the same version are +available. \ No newline at end of file From e9d5bb902fe72106c56204d0f7ec2fb238fda67d Mon Sep 17 00:00:00 2001 From: Martin Boisvert Date: Wed, 18 Jan 2023 13:49:10 -0500 Subject: [PATCH 04/10] Added final newline --- .../next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst b/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst index 419f47a511fb53..2e6d6371340d89 100644 --- a/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst +++ b/Misc/NEWS.d/next/Windows/2023-01-18-18-25-18.gh-issue-101135.HF9VlG.rst @@ -1,3 +1,3 @@ Restore ability to launch older 32-bit versions from the :file:`py.exe` launcher when both 32-bit and 64-bit installs of the same version are -available. \ No newline at end of file +available. From d41e4ce7dfd48c585984d3f7d149a0ca2ce7efe8 Mon Sep 17 00:00:00 2001 From: Martin Boisvert Date: Fri, 20 Jan 2023 16:43:17 -0500 Subject: [PATCH 05/10] Implement _registryBackCompat --- PC/launcher2.c | 133 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 95 insertions(+), 38 deletions(-) diff --git a/PC/launcher2.c b/PC/launcher2.c index 727f9e09432d7f..d1ff1d4af51281 100644 --- a/PC/launcher2.c +++ b/PC/launcher2.c @@ -1293,28 +1293,6 @@ _compareTag(const wchar_t *x, const wchar_t *y) } -int -_compareArch(const wchar_t *x, const wchar_t *y) -{ - if (!x && !y) { - return 0; - } else if (!x) { - return -1; - } else if (!y) { - return 1; - } - - bool is64X = 0 == _compare(x, -1, L"64bit", -1); - bool is64Y = 0 == _compare(y, -1, L"64bit", -1); - if (is64X) { - return is64Y ? 0 : -1; - } else if (is64Y) { - return 1; - } - return _compare(x, -1, y, -1); -} - - int addEnvironmentInfo(EnvironmentInfo **root, EnvironmentInfo* parent, EnvironmentInfo *node) { @@ -1342,15 +1320,6 @@ addEnvironmentInfo(EnvironmentInfo **root, EnvironmentInfo* parent, EnvironmentI case 0: break; } - // Then by architecture - switch (_compareArch(node->architecture, r->architecture)) { - case -1: - return addEnvironmentInfo(&r->prev, r, node); - case 1: - return addEnvironmentInfo(&r->next, r, node); - case 0: - break; - } // Then keep the one with the lowest internal sort key if (node->internalSortKey < r->internalSortKey) { // Replace the current node @@ -1429,6 +1398,93 @@ _combineWithInstallDir(const wchar_t **dest, const wchar_t *installDir, const wc return copyWstr(dest, buffer); } +// There is one notable situation which I'm not sure how to handle: +// Python 3.5 has an executablePath but no windowedExecutablePath. +// With the code as written, running pyw -3.5 will launch python.exe rather than pythonw.exe. + + // if + // * PythonCore and + // * legacyVersion + // * 2.X or + // * 3.X where X < 5 or X <= 5 (todo: which?) + // then + // call back-compat function + // * if fallbackArch is not null, (move the above code to here?) + // * if fallbackArch is null, set env->architecture from checking the executable's binary type + // * if env->architecture is 32bit, update tag by appending "-32" +int +_registryBackCompat(const SearchInfo *search, EnvironmentInfo *env, const wchar_t *fallbackArch) +{ + // Support backwards-compatibility for old PythonCore versions which do not implement PEP 514. + // These are specifically 2.X and 3.0 - 3.5. + + // Non-PythonCore versions and PythonCore versions which already have an architecture + // require no compatibility handling. + if (0 != _compare(env->company, -1, L"PythonCore", -1) || env->architecture) { + return 0; + } + + int versionMajor, versionMinor; + int n = swscanf(env->tag, L"%d.%d", &versionMajor, &versionMinor); + if (n != 2) { + debug(L"# %s/%s has an invalid version tag\n", env->company, env->tag); + return RC_NO_PYTHON; + } + + bool isLegacyVersion = + versionMajor == 2 || + (versionMajor == 3 && versionMinor >= 0 && versionMinor <= 5); + + if (!isLegacyVersion) { + debug(L"# %s/%s does not follow PEP 514, but is not a known legacy version\n", env->company, env->tag); + return RC_NO_PYTHON; + } + + // TODO: Ensure executablePath is set by this point, or else + // GetBinaryType will not work. + + if (fallbackArch) { + copyWstr(&env->architecture, fallbackArch); + } else { + DWORD binaryType; + BOOL success = GetBinaryTypeW(env->executablePath, &binaryType); + if (!success) { + return RC_NO_PYTHON; + } + + switch (binaryType) { + case SCS_32BIT_BINARY: + copyWstr(&env->architecture, L"32bit"); + break; + case SCS_64BIT_BINARY: + copyWstr(&env->architecture, L"64bit"); + break; + default: + return RC_NO_PYTHON; + } + } + + if (0 == _compare(env->architecture, -1, L"32bit", -1)) { + int tagLength = wcslen(env->tag); + if (tagLength <= 3 || 0 != _compare(&env->tag[tagLength - 3], 3, L"-32", 3)) { + wchar_t *rawTag = env->tag; + wchar_t *realTag = (wchar_t*) malloc(sizeof(wchar_t) * (tagLength + 4)); + if (!realTag) { + return RC_NO_MEMORY; + } + + int count = swprintf_s(realTag, tagLength + 4, L"%s-32", env->tag); + if (count == -1) { + free(realTag); + return RC_INTERNAL_ERROR; + } + + env->tag = realTag; + free(rawTag); + } + } +} + int _registryReadEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *env, const wchar_t *fallbackArch) @@ -1496,6 +1552,7 @@ _registryReadEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *e return RC_NO_PYTHON; } + return 0; } @@ -2155,13 +2212,13 @@ _listAllEnvironments(EnvironmentInfo *env, FILE * out, bool showPath, Environmen } else if (0 == _compare(env->company, -1, L"PythonCore", -1)) { swprintf_s(buffer, bufferSize, L"-V:%s", env->tag); - // append "-32" to PythonCore 32-bit environments if it isn't already specified in the tag name - if (0 == _compare(env->architecture, -1, L"32bit", -1)) { - int tagLength = wcslen(env->tag); - if (tagLength <= 3 || 0 != _compare(&env->tag[tagLength - 3], 3, L"-32", 3)) { - wcscat_s(buffer, bufferSize, L"-32"); - } - } + //// append "-32" to PythonCore 32-bit environments if it isn't already specified in the tag name + //if (0 == _compare(env->architecture, -1, L"32bit", -1)) { + // int tagLength = wcslen(env->tag); + // if (tagLength <= 3 || 0 != _compare(&env->tag[tagLength - 3], 3, L"-32", 3)) { + // wcscat_s(buffer, bufferSize, L"-32"); + // } + //} } else { swprintf_s(buffer, bufferSize, L"-V:%s/%s", env->company, env->tag); } From 4b1cb626a6ab37d2aaa6ae5286877c658279b9e3 Mon Sep 17 00:00:00 2001 From: Martin Boisvert Date: Fri, 20 Jan 2023 16:50:21 -0500 Subject: [PATCH 06/10] resolve warnings --- PC/launcher2.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/PC/launcher2.c b/PC/launcher2.c index d1ff1d4af51281..7ed5c781433e7a 100644 --- a/PC/launcher2.c +++ b/PC/launcher2.c @@ -1425,7 +1425,7 @@ _registryBackCompat(const SearchInfo *search, EnvironmentInfo *env, const wchar_ } int versionMajor, versionMinor; - int n = swscanf(env->tag, L"%d.%d", &versionMajor, &versionMinor); + int n = swscanf_s(env->tag, L"%d.%d", &versionMajor, &versionMinor); if (n != 2) { debug(L"# %s/%s has an invalid version tag\n", env->company, env->tag); return RC_NO_PYTHON; @@ -1465,9 +1465,9 @@ _registryBackCompat(const SearchInfo *search, EnvironmentInfo *env, const wchar_ } if (0 == _compare(env->architecture, -1, L"32bit", -1)) { - int tagLength = wcslen(env->tag); + size_t tagLength = wcslen(env->tag); if (tagLength <= 3 || 0 != _compare(&env->tag[tagLength - 3], 3, L"-32", 3)) { - wchar_t *rawTag = env->tag; + const wchar_t *rawTag = env->tag; wchar_t *realTag = (wchar_t*) malloc(sizeof(wchar_t) * (tagLength + 4)); if (!realTag) { return RC_NO_MEMORY; @@ -1480,9 +1480,11 @@ _registryBackCompat(const SearchInfo *search, EnvironmentInfo *env, const wchar_ } env->tag = realTag; - free(rawTag); + free((void*)rawTag); } } + + return 0; } From 0a01165dcbfd7519af7d7ab37b5ac1463c039876 Mon Sep 17 00:00:00 2001 From: Martin Boisvert Date: Mon, 23 Jan 2023 15:35:08 -0500 Subject: [PATCH 07/10] Move all PythonCore, back-compat related stuff over to _registryReadLegacyEnvironment --- PC/launcher2.c | 104 ++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 57 deletions(-) diff --git a/PC/launcher2.c b/PC/launcher2.c index 7ed5c781433e7a..f63d1da6e4a4e3 100644 --- a/PC/launcher2.c +++ b/PC/launcher2.c @@ -1398,51 +1398,42 @@ _combineWithInstallDir(const wchar_t **dest, const wchar_t *installDir, const wc return copyWstr(dest, buffer); } -// There is one notable situation which I'm not sure how to handle: -// Python 3.5 has an executablePath but no windowedExecutablePath. -// With the code as written, running pyw -3.5 will launch python.exe rather than pythonw.exe. - - // if - // * PythonCore and - // * legacyVersion - // * 2.X or - // * 3.X where X < 5 or X <= 5 (todo: which?) - // then - // call back-compat function - // * if fallbackArch is not null, (move the above code to here?) - // * if fallbackArch is null, set env->architecture from checking the executable's binary type - // * if env->architecture is 32bit, update tag by appending "-32" -int -_registryBackCompat(const SearchInfo *search, EnvironmentInfo *env, const wchar_t *fallbackArch) -{ - // Support backwards-compatibility for old PythonCore versions which do not implement PEP 514. - // These are specifically 2.X and 3.0 - 3.5. - // Non-PythonCore versions and PythonCore versions which already have an architecture - // require no compatibility handling. - if (0 != _compare(env->company, -1, L"PythonCore", -1) || env->architecture) { - return 0; +bool +_isLegacyVersion(EnvironmentInfo *env) +{ + // Check if backwards-compatibility is required. + // Specifically PythonCore versions 2.X and 3.0 - 3.5 do not implement PEP 514. + if (0 != _compare(env->company, -1, L"PythonCore", -1)) { + return false; } int versionMajor, versionMinor; int n = swscanf_s(env->tag, L"%d.%d", &versionMajor, &versionMinor); if (n != 2) { debug(L"# %s/%s has an invalid version tag\n", env->company, env->tag); - return RC_NO_PYTHON; + return false; } - bool isLegacyVersion = - versionMajor == 2 || - (versionMajor == 3 && versionMinor >= 0 && versionMinor <= 5); + return versionMajor == 2 + || (versionMajor == 3 && versionMinor >= 0 && versionMinor <= 5); +} - if (!isLegacyVersion) { - debug(L"# %s/%s does not follow PEP 514, but is not a known legacy version\n", env->company, env->tag); - return RC_NO_PYTHON; +// Backwards-compatibility for old PythonCore versions which do not implement PEP 514. +// These are specifically 2.X and 3.0 - 3.5. +int +_registryReadLegacyEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *env, const wchar_t *fallbackArch) +{ + int exitCode = _combineWithInstallDir( + &env->executablePath, + env->installDir, + search->executable, + search->executableLength + ); + if (exitCode) { + return exitCode; } - // TODO: Ensure executablePath is set by this point, or else - // GetBinaryType will not work. - if (fallbackArch) { copyWstr(&env->architecture, fallbackArch); } else { @@ -1484,6 +1475,20 @@ _registryBackCompat(const SearchInfo *search, EnvironmentInfo *env, const wchar_ } } + wchar_t buffer[MAXLEN]; + if (swprintf_s(buffer, MAXLEN, L"Python %s", env->tag)) { + copyWstr(&env->displayName, buffer); + } + + if (search->windowed) { + exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"WindowedExecutableArguments"); + } else { + exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"ExecutableArguments"); + } + if (exitCode) { + return exitCode; + } + return 0; } @@ -1499,6 +1504,10 @@ _registryReadEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *e return RC_NO_PYTHON; } + if (_isLegacyVersion(env)) { + return _registryReadLegacyEnvironment(search, root, env, fallbackArch); + } + // If pythonw.exe requested, check specific value if (search->windowed) { exitCode = _registryReadString(&env->executablePath, root, L"InstallPath", L"WindowedExecutablePath"); @@ -1521,6 +1530,11 @@ _registryReadEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *e return exitCode; } + if (!env->executablePath) { + debug(L"# %s/%s has no executable path\n", env->company, env->tag); + return RC_NO_PYTHON; + } + exitCode = _registryReadString(&env->architecture, root, NULL, L"SysArchitecture"); if (exitCode) { return exitCode; @@ -1531,30 +1545,6 @@ _registryReadEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *e return exitCode; } - // Only PythonCore entries will infer executablePath from installDir and architecture from the binary - if (0 == _compare(env->company, -1, L"PythonCore", -1)) { - if (!env->executablePath) { - exitCode = _combineWithInstallDir( - &env->executablePath, - env->installDir, - search->executable, - search->executableLength - ); - if (exitCode) { - return exitCode; - } - } - if (!env->architecture && env->executablePath && fallbackArch) { - copyWstr(&env->architecture, fallbackArch); - } - } - - if (!env->executablePath) { - debug(L"# %s/%s has no executable path\n", env->company, env->tag); - return RC_NO_PYTHON; - } - - return 0; } From 69aeff37bbc700e4b3df853d7b73ab71f3e13b26 Mon Sep 17 00:00:00 2001 From: Martin Boisvert Date: Mon, 23 Jan 2023 15:37:00 -0500 Subject: [PATCH 08/10] move comment --- PC/launcher2.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/PC/launcher2.c b/PC/launcher2.c index f63d1da6e4a4e3..04f638d074b1a8 100644 --- a/PC/launcher2.c +++ b/PC/launcher2.c @@ -1419,11 +1419,10 @@ _isLegacyVersion(EnvironmentInfo *env) || (versionMajor == 3 && versionMinor >= 0 && versionMinor <= 5); } -// Backwards-compatibility for old PythonCore versions which do not implement PEP 514. -// These are specifically 2.X and 3.0 - 3.5. int _registryReadLegacyEnvironment(const SearchInfo *search, HKEY root, EnvironmentInfo *env, const wchar_t *fallbackArch) { + // Backwards-compatibility for PythonCore versions which do not implement PEP 514. int exitCode = _combineWithInstallDir( &env->executablePath, env->installDir, From b0ec9965940e4d53b104049fa758e9e6bf574efb Mon Sep 17 00:00:00 2001 From: Martin Boisvert Date: Mon, 23 Jan 2023 18:13:01 -0500 Subject: [PATCH 09/10] reordered code --- PC/launcher2.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/PC/launcher2.c b/PC/launcher2.c index 04f638d074b1a8..bfb9bc41bf3ac7 100644 --- a/PC/launcher2.c +++ b/PC/launcher2.c @@ -1433,6 +1433,16 @@ _registryReadLegacyEnvironment(const SearchInfo *search, HKEY root, EnvironmentI return exitCode; } + if (search->windowed) { + exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"WindowedExecutableArguments"); + } + else { + exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"ExecutableArguments"); + } + if (exitCode) { + return exitCode; + } + if (fallbackArch) { copyWstr(&env->architecture, fallbackArch); } else { @@ -1479,15 +1489,6 @@ _registryReadLegacyEnvironment(const SearchInfo *search, HKEY root, EnvironmentI copyWstr(&env->displayName, buffer); } - if (search->windowed) { - exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"WindowedExecutableArguments"); - } else { - exitCode = _registryReadString(&env->executableArgs, root, L"InstallPath", L"ExecutableArguments"); - } - if (exitCode) { - return exitCode; - } - return 0; } From 62b404caea2818c2ba3927c48481de9651502b2c Mon Sep 17 00:00:00 2001 From: Martin Boisvert Date: Mon, 23 Jan 2023 18:26:59 -0500 Subject: [PATCH 10/10] Removed commented code --- PC/launcher2.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/PC/launcher2.c b/PC/launcher2.c index bfb9bc41bf3ac7..4c77ec0be43914 100644 --- a/PC/launcher2.c +++ b/PC/launcher2.c @@ -2203,14 +2203,6 @@ _listAllEnvironments(EnvironmentInfo *env, FILE * out, bool showPath, Environmen buffer[0] = L'\0'; } else if (0 == _compare(env->company, -1, L"PythonCore", -1)) { swprintf_s(buffer, bufferSize, L"-V:%s", env->tag); - - //// append "-32" to PythonCore 32-bit environments if it isn't already specified in the tag name - //if (0 == _compare(env->architecture, -1, L"32bit", -1)) { - // int tagLength = wcslen(env->tag); - // if (tagLength <= 3 || 0 != _compare(&env->tag[tagLength - 3], 3, L"-32", 3)) { - // wcscat_s(buffer, bufferSize, L"-32"); - // } - //} } else { swprintf_s(buffer, bufferSize, L"-V:%s/%s", env->company, env->tag); }