-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-124960: Fixed barry_as_FLUFL
future flag does not work in new REPL
#124999
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
Conversation
… the beginning of the file (console.py, line 21)
Misc/NEWS.d/next/Library/2024-10-05-15-49-53.gh-issue-124960.Bol9hT.rst
Outdated
Show resolved
Hide resolved
You can close this, I have a proper fix. |
ce801c7
to
904c202
Compare
Co-authored-by: Nice Zombies <[email protected]>
After my testing, your patch solved this bug. I added a co-author, but I need ask your opinion so that we can open one less PR edit: tests fail. |
Co-authored-by: Nice Zombies <[email protected]>
with contextlib.redirect_stdout(f): | ||
result = console.runsource("from __future__ import barry_as_FLUFL\n") | ||
result = console.runsource("""print("black" <> 'blue')\n""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required because the parser can't deal with the future import changing the flags inside a run. This is true now:
❯ ./python.exe -c "from __future__ import barry_as_FLUFL; 1<>0"
File "<string>", line 1
from __future__ import barry_as_FLUFL; 1<>0
^^
SyntaxError: invalid syntax
but was also true in the old parser:
❯ python3.9 -Xoldparser -c "from __future__ import barry_as_FLUFL; 1<>0"
File "<string>", line 1
from __future__ import barry_as_FLUFL; 1<>0
^
SyntaxError: invalid syntax
The consequence of that with PyREPL is that you cannot paste multiline blocks with that future and make them run, because PyREPL executes everything save for the last line in one go.
PyREPL isn't doing anything wrong here, it's just exposing the bug that was always there. Therefore, I'm not sure we should be working around this pasting thing for this one future. Other futures work fine, as you can see in the test added above.
Thanks @Wulian233 for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @Wulian233 and @ambv, I could not cleanly backport this to
|
GH-125475 is a backport of this pull request to the 3.13 branch. |
…new REPL (python#124999) Co-authored-by: Nice Zombies <[email protected]> Co-authored-by: Łukasz Langa <[email protected]> (cherry picked from commit 6a08a75)
… new REPL (#124999) (#125475) gh-124960: Fixed `barry_as_FLUFL` future flag does not work in new REPL (#124999) Co-authored-by: Wulian <[email protected]> Co-authored-by: Nice Zombies <[email protected]> Co-authored-by: Łukasz Langa <[email protected]> (cherry picked from commit 6a08a75)
co-author: nineteendo armv
barry_as_FLUFL
future flag does not work in new REPL #124960