Skip to content

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

Merged
merged 9 commits into from
Oct 14, 2024

Conversation

Wulian233
Copy link
Contributor

@Wulian233 Wulian233 commented Oct 5, 2024

@Wulian233 Wulian233 marked this pull request as draft October 5, 2024 08:06
@nineteendo
Copy link
Contributor

You can close this, I have a proper fix.

@Wulian233
Copy link
Contributor Author

Wulian233 commented Oct 6, 2024

You can close this, I have a proper fix.

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.

@Wulian233 Wulian233 marked this pull request as ready for review October 6, 2024 06:27
Comment on lines +148 to +150
with contextlib.redirect_stdout(f):
result = console.runsource("from __future__ import barry_as_FLUFL\n")
result = console.runsource("""print("black" <> 'blue')\n""")
Copy link
Contributor

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.

@ambv ambv merged commit 6a08a75 into python:main Oct 14, 2024
42 checks passed
@ambv ambv added the needs backport to 3.13 bugs and security fixes label Oct 14, 2024
@miss-islington-app
Copy link

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

@miss-islington-app
Copy link

Sorry, @Wulian233 and @ambv, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 6a08a753b702ac63c9b6ac58dd204d1fe9662e9d 3.13

@bedevere-app
Copy link

bedevere-app bot commented Oct 14, 2024

GH-125475 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Oct 14, 2024
nineteendo added a commit to nineteendo/cpython that referenced this pull request Oct 14, 2024
…new REPL (python#124999)

Co-authored-by: Nice Zombies <[email protected]>
Co-authored-by: Łukasz Langa <[email protected]>
(cherry picked from commit 6a08a75)
ambv added a commit that referenced this pull request Oct 14, 2024
… 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)
@Wulian233 Wulian233 deleted the barry_as_FLUFL branch October 14, 2024 22:22
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.

5 participants