-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Python 3.11.0b4 - py launcher fails when running a script with a shebang line #94772
Comments
OK, I just did a bisect, and found the bad commit was bad86a6 "bpo-46566: Add new py.exe launcher implementation (GH-32062)". Sigh, I suppose that should have been rather obvious 🙂 @zooba Any insights as to what's wrong here? As it's a complete new implementation, I don't honestly know where to look... @pablogsal This is a fairly serious issue (assuming it's reproducible elsewhere and isn't somehow tied to something peculiar on my system), so it may warrant being labelled as a release blocker. Sorry! |
Added release blocker label for 3.11.0b5 |
I just found out that there's debug logging in the launcher. Debug info:
|
I'm going to assume it's an off-by-one error in this line or three lines down where we add 1 to calculate the length of the string. Embarrassingly, the tests only test scripts with nothing after the shebang 🤦♂️ So adding a second line to the shebang tests will show the issue. I probably won't get time to fix anything this week, so feel free, otherwise once I'm back at work I'll get to it. |
Yes, that was it - good catch! I have a fix, but I can't test it against main because I'm getting build errors when I try to build there:
I'm not sure what to do about this. I can submit a PR, and simply hope that it has no issues (or at least that CI or the buildbots will catch any that do exist). I did build the same change against 3.11.0b4 and ran the test suite, but I'm getting failures there:
I'm afraid I don't have time right now to work out what's going on here. I assume it's probably something not right with my local setup (it's been a long time since I built CPython from source). For now, I've created #94779 with the basic fix. I can try to find time to get my build environment working properly and then complete that PR. But if someone wants to take what's in that PR and make a proper PR in the meantime, I'm fine with that. |
lol, the three existing tests for the shebang all use a "script" that is a single line with no terminating newline. So they all fail with the fix I've made. On the assumption that we want to support files with just a shebang and no newline or content (I'm not sure why we do, but I'm not going to make that call...) I'll update my fix and add some tests for the case where there is a newline... |
I mean, we want them all to work, but I'd definitely rather have files with content also work. There shouldn't be any reason that both can't work though, it just makes the logic for stripping off trailing New tests would be great. |
Done, and the PR has passed CI. If you have a chance to review, that would be great. BTW, I found the logic in that bit of code pretty hard to follow. I didn't change it because I wanted to just do the minimal change necessary, but would you be OK with a follow-up to make the code a bit more verbose but (hopefully!) clearer? |
) (cherry picked from commit 407ff65) Co-authored-by: Paul Moore <p.f.moore@gmail.com>
Bug report
When running a script with a "shebang" line, the
py.exe
launcher in Python 3.11.0b4 fails with an error:To reproduce, create the following script as
x.py
:Run the script using
py.exe
built from a 3.11.0b4 checkout usingbuild.bat
:Note the truncated python executable name. This appears to be related to the use of CRLF line endings in the file - if I switch to LF line endings, I get
Your environment
The text was updated successfully, but these errors were encountered: