8000 bpo-38344 else needs to be on the same line as the if by jamesabel · Pull Request #16533 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-38344 else needs to be on the same line as the if #16533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 7, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
else needs to be on the same line as the if
  • Loading branch information
jamesabel committed Oct 2, 2019
commit c7cf323c2d21fdc6ae756ca2a12789aa9abc022f
3 changes: 1 addition & 2 deletions Lib/venv/scripts/nt/activate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ set PROMPT=__VENV_PROMPT__%PROMPT%
if defined PYTHONHOME set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
set PYTHONHOME=

if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
else set _OLD_VIRTUAL_PATH=%PATH%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore the old syntax and replace the else with if not defined ....

if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH% else set _OLD_VIRTUAL_PATH=%PATH%
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will never execute the else clause, and if _OLD_VIRTUAL_PATH is defined it will set PATH literally to the evaluation of the string "%_OLD_VIRTUAL_PATH% else set _OLD_VIRTUAL_PATH=%PATH%".

Why again were parentheses stripped out of this script? Whatever the reason, there must be a better way. It's dysfunctional to not be able to write this statement as follows:

if defined _OLD_VIRTUAL_PATH (
    set PATH=%_OLD_VIRTUAL_PATH%
) else (
    set _OLD_VIRTUAL_PATH=%PATH%
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't mention it previously, but in the current form the script errors out:

C:\Program Files\Python38\Lib\venv\scripts\nt>activate.bat
'else' is not recognized as an internal or external command,
operable program or batch file.

But good point on the parenthesis to make it function properly again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parentheses were stripped out because stray parentheses and quotes were breaking the script for people.

Having if defined ... followed by if not defined ... on separate (single) lines is probably the best approach.


set PATH=%VIRTUAL_ENV%\__VENV_BIN_NAME__;%PATH%

Expand Down
0