8000 bpo-34532: Fixed exit code for py.exe list versions arg · python/cpython@10e01f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10e01f0

Browse files
committed
bpo-34532: Fixed exit code for py.exe list versions arg
1 parent 4b5c00d commit 10e01f0

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

PC/launcher.c

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,7 @@ show_python_list(wchar_t ** argv)
14541454
fwprintf(stderr, L"\n\nCan't find a Default Python.\n\n");
14551455
else
14561456
fwprintf(stderr, L"\n\n"); /* End with a blank line */
1457-
return(FALSE); /* If this has been called we cannot continue */
1457+
return FALSE; /* If this has been called we cannot continue */
14581458
}
14591459

14601460
static int
@@ -1468,7 +1468,6 @@ process(int argc, wchar_t ** argv)
14681468
size_t plen;
14691469
INSTALLED_PYTHON * ip;
14701470
BOOL valid;
1471-
BOOL version_call = FALSE;
14721471
DWORD size, attrs;
14731472
HRESULT hr;
14741473
wchar_t message[MSGSIZE];
@@ -1601,15 +1600,15 @@ process(int argc, wchar_t ** argv)
16011600
}
16021601
else {
16031602
p = argv[1];
1604-
if ((argc == 2) &&
1605-
(!_wcsicmp(p, L"-0") || !_wcsicmp(p, L"--list") || /* Version args. */
1606-
!_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths")))
1603+
plen = wcslen(p);
1604+
if ((argc == 2) && // list version args
1605+
(!wcsncmp(p, L"-0", wcslen(L"-0")) ||
1606+
!wcsncmp(p, L"--list", wcslen(L"--list"))))
16071607
{
16081608
show_python_list(argv);
1609-
version_call = TRUE;
1610-
executable = NULL;
1609+
return rc;
16111610
}
1612-
valid = !version_call && (*p == L'-') && validate_version(&p[1]);
1611+
valid = valid && (*p == L'-') && validate_version(&p[1]);
16131612
if (valid) {
16141613
ip = locate_python(&p[1], FALSE);
16151614
if (ip == NULL)
@@ -1640,25 +1639,29 @@ installed, use -0 for available pythons", &p[1]);
16401639
if (!valid) {
16411640
if ((argc == 2) && (!_wcsicmp(p, L"-h") || !_wcsicmp(p, L"--help")))
16421641
show_help_text(argv);
1643-
1644-
/* Look for an active virtualenv */
1645-
executable = find_python_by_venv();
1646-
1647-
/* If we didn't find one, look for the default Python */
1648-
if (executable == NULL) {
1649-
ip = locate_python(L"", FALSE);
1650-
if (ip == NULL)
1651-
error(RC_NO_PYTHON, L"Can't find a default Python.");
1652-
executable = ip->executable;
1642+
if ((argc == 2) &&
1643+
(!_wcsicmp(p, L"-0") || !_wcsicmp(p, L"--list") ||
1644+
!_wcsicmp(p, L"-0p") || !_wcsicmp(p, L"--list-paths")))
1645+
{
1646+
executable = NULL; /* Info call only */
1647+
}
1648+
else {
1649+
/* Look for an active virtualenv */
1650+
executable = find_python_by_venv();
1651+
1652+
/* If we didn't find one, look for the default Python */
1653+
if (executable == NULL) {
1654+
ip = locate_python(L"", FALSE);
1655+
if (ip == NULL)
1656+
error(RC_NO_PYTHON, L"Can't find a default Python.");
1657+
executable = ip->executable;
1658+
}
16531659
}
16541660
}
1655-
if (executable == NULL) {
1656-
rc = RC_NO_PYTHON;
1657-
}
1658-
else if (!version_call) {
1661+
if (executable != NULL)
16591662
invoke_child(executable, NULL, command);
1660-
}
1661-
1663+
else
1664+
rc = RC_NO_PYTHON;
16621665
return rc;
16631666
}
16641667

0 commit comments

Comments
 (0)
0