Skip to content

gh-94772: Fix off-by-one error in Windows launcher #94779

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 3 commits into from
Jul 16, 2022

Conversation

pfmoore
Copy link
Member

@pfmoore pfmoore commented Jul 12, 2022

@pfmoore pfmoore requested a review from a team as a code owner July 12, 2022 15:00
@pfmoore pfmoore changed the title Fix off-by-one error in Windows launcher gh-94772: Fix off-by-one error in Windows launcher Jul 12, 2022
@pelson
Copy link
Contributor

pelson commented Jul 13, 2022

Was just doing a fly-by look at the implementation out of curiosity. Since I'm here, I noticed that there doesn't appear to be a single test which checks a shebang without a space before the first command (e.g. #!/usr/bin/env python). Since this is the common case in Unix (though the leading space is peppered throughout PEP 397), I would recommend to add such a test.

Quoting wikipedia on the issue:

It has been claimed[20] that some old versions of Unix expect the normal shebang to be followed by a space and a slash (#! /), but this appears to be untrue;[21] rather, blanks after the shebang have traditionally been allowed, and sometimes documented with a space (see the 1980 email in history section below)

@pfmoore
Copy link
Member Author

pfmoore commented Jul 13, 2022

+1 on more tests, and the one you suggest seems reasonable. Ideally, I'd test a variety of scripts using parametrised tests, but I'm not sure how to do those in unittest...

The main focus of this PR is to fix the regression in the launcher, so I'd suggest extra tests get added in a follow-up PR, though.

@zooba zooba added the needs backport to 3.11 only security fixes label Jul 16, 2022
@zooba zooba merged commit 407ff65 into python:main Jul 16, 2022
@miss-islington
Copy link
Contributor

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 16, 2022
@bedevere-bot
Copy link

GH-94896 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 16, 2022
zooba pushed a commit that referenced this pull request Jul 16, 2022
(cherry picked from commit 407ff65)

Co-authored-by: Paul Moore <[email protected]>

Co-authored-by: Paul Moore <[email protected]>
@pfmoore pfmoore deleted the launcher_fix branch July 16, 2022 12:49
@pfmoore
Copy link
Member Author

pfmoore commented Jul 16, 2022

Thanks @zooba for merging this.

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.

Python 3.11.0b4 - py launcher fails when running a script with a shebang line
5 participants