summaryrefslogtreecommitdiffstats
path: root/PC
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-07-28 20:52:13 (GMT)
committerGitHub <noreply@github.com>2022-07-28 20:52:13 (GMT)
commit1368a1f724ebcab803644adbf764d8d30b18cfd0 (patch)
tree888af1124d692e7e95539ba2ec9cf8a4953d9a59 /PC
parent9626dea86f500aa7bc4bbe7920842f979feee527 (diff)
downloadcpython-1368a1f724ebcab803644adbf764d8d30b18cfd0.zip
cpython-1368a1f724ebcab803644adbf764d8d30b18cfd0.tar.gz
cpython-1368a1f724ebcab803644adbf764d8d30b18cfd0.tar.bz2
gh-95359: Fix py.exe launcher handling of per-user py.ini and command names (GH-95399)
(cherry picked from commit 38bb2068fe1f51a74b36c46e820abc5f6422cded) Co-authored-by: Steve Dower <steve.dower@python.org>
Diffstat (limited to 'PC')
-rw-r--r--PC/launcher2.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/PC/launcher2.c b/PC/launcher2.c
index 31b5617..033218e 100644
--- a/PC/launcher2.c
+++ b/PC/launcher2.c
@@ -761,7 +761,7 @@ _readIni(const wchar_t *section, const wchar_t *settingName, wchar_t *buffer, in
n = GetPrivateProfileStringW(section, settingName, NULL, buffer, bufferLength, iniPath);
if (n) {
debug(L"# Found %s in %s\n", settingName, iniPath);
- return true;
+ return n;
} else if (GetLastError() == ERROR_FILE_NOT_FOUND) {
debug(L"# Did not find file %s\n", iniPath);
} else {
@@ -946,13 +946,17 @@ checkDefaults(SearchInfo *search)
// If tag is only a major version number, expand it from the environment
// or an ini file
- const wchar_t *settingName = NULL;
+ const wchar_t *iniSettingName = NULL;
+ const wchar_t *envSettingName = NULL;
if (!search->tag || !search->tagLength) {
- settingName = L"py_python";
+ iniSettingName = L"python";
+ envSettingName = L"py_python";
} else if (0 == wcsncmp(search->tag, L"3", search->tagLength)) {
- settingName = L"py_python3";
+ iniSettingName = L"python3";
+ envSettingName = L"py_python3";
} else if (0 == wcsncmp(search->tag, L"2", search->tagLength)) {
- settingName = L"py_python2";
+ iniSettingName = L"python2";
+ envSettingName = L"py_python2";
} else {
debug(L"# Cannot select defaults for tag '%.*s'\n", search->tagLength, search->tag);
return 0;
@@ -960,11 +964,11 @@ checkDefaults(SearchInfo *search)
// First, try to read an environment variable
wchar_t buffer[MAXLEN];
- int n = GetEnvironmentVariableW(settingName, buffer, MAXLEN);
+ int n = GetEnvironmentVariableW(envSettingName, buffer, MAXLEN);
// If none found, check in our two .ini files instead
if (!n) {
- n = _readIni(L"defaults", settingName, buffer, MAXLEN);
+ n = _readIni(L"defaults", iniSettingName, buffer, MAXLEN);
}
if (n) {