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

Conversation

jamesabel
Copy link
Contributor
@jamesabel jamesabel commented Oct 2, 2019

In activate.bat the else needs to be on the same line as the if

https://bugs.python.org/issue38344

@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@jamesabel

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@@ -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%
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.

@zware zware requested a review from zooba October 2, 2019 14:39
Copy link
Member
@zooba zooba left a comment

Choose a reason for hiding this comment

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

Also see the issue for ideas about making sure this is tested properly.

@@ -21,8 +21,11 @@ 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 ....

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

And if you don't make the requested changes, you will be poked with soft cushions!

@jamesabel jamesabel requested a review from vsajip as a code owner October 5, 2019 04:51
@jamesabel
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@zooba: please review the changes made to this pull request.

if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
else set _OLD_VIRTUAL_PATH=%PATH%
if defined _OLD_VIRTUAL_PATH set "PATH=%_OLD_VIRTUAL_PATH%"
if not defined _OLD_VIRTUAL_PATH 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.

Need to lose the quotes as well - they can cause problems if there are mismatched quotes in the variables (and they're not necessary when the statement extends to the end of the line, which is why the original change was necessary).

@@ -0,0 +1 @@
Fix usage of _OLD_VIRTUAL_PATH in activate.bat. Do not use parenthesis in the if statement. Instead of if/else, use if defined/if not defined on separate lines.
Copy link
Member

Choose a reason for hiding this comment

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

The NEWS item doesn't need to be this detailed - it'll link back to the bug, which links to the PR, which links to the changes for anyone interested. Simply saying "Fix error message in activate.bat" would be fine.

@jamesabel
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@zooba: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from zooba October 7, 2019 20:32
@zooba zooba merged commit e310af9 into python:master Oct 7, 2019
@miss-islington
Copy link
Contributor

Thanks @jamesabel for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7, 3.8.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry @jamesabel and @zooba, I had trouble checking out the 3.8 backport branch.
Please backport using cherry_picker on command line.
cherry_picker e310af9e2941c2fbb7370e003276cc37eb230f16 3.8

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 7, 2019
(cherry picked from commit e310af9)

Co-authored-by: James Abel <j@abel.co>
@bedevere-bot
Copy link

GH-16627 is a backport of this pull request to the 3.7 branch.

@zooba
Copy link
Member
zooba commented Oct 7, 2019

Thanks! I've merged it as-is, since we need the fix, but we'll leave the bug open for now to consider enhancing the test suite as well.

@miss-islington
Copy link
Contributor

Thanks @jamesabel for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 7, 2019
(cherry picked from commit e310af9)

Co-authored-by: James Abel <j@abel.co>
@bedevere-bot
Copy link

GH-16628 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Oct 7, 2019
(cherry picked from commit e310af9)

Co-authored-by: James Abel <j@abel.co>
miss-islington added a commit that referenced this pull request Oct 7, 2019
(cherry picked from commit e310af9)

Co-authored-by: James Abel <j@abel.co>
ned-deily pushed a commit to ned-deily/cpython that referenced this pull request Oct 14, 2019
(cherry picked from commit e310af9)

Co-authored-by: James Abel <j@abel.co>
jacobneiltaylor pushed a commit to jacobneiltaylor/cpython that referenced this pull request Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0