-
-
Notifications
You must be signed in to change notification settings - Fork 32k
from __future__ import barry_as_FLUFL
doesn't work
#125331
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
Comments
We would have to be careful to make sure that this easter egg can't be used in production... |
This issue was discussed recently, and IDLE is not a bug |
Clearly this should be a blocker for all upcoming releases 😄 |
I'm investigating and working on a possible fix. I am not fully convinced that is a but but I agree it looks like one. |
Not really: the parser receives all its configuration when executed, including the flags. The parser cannot change the configuration mid execution (among other things because it doesn't "know" what an import is supposed to do).
The way most futures work is by changing the compiler, not the parser. This is the exception and in reality is not even an exception because the way this was added was to only work in interactive mode. Indeed if you try this in a file:
it won't work:
Is only prepared to work on sequential-execution where the previous statement modifies the flags. That's why it works in the REPL:
this is because when executing the first statement, the second call to parse changed flags. But this only happened after it was executed (not parsed). |
The toll to fix this is not trivial: every call to parse/compile would need to be actually 2 calls to parse/compile OR we need to teach the parser to change flags mid run (which is not trivial because future imports have certain restrictions):
gives:
and these restrictions are not checked by the parser but the compiler (in the symbol table): Line 1777 in 843d28f
|
I think that given that this will introduce some slowness to fix or maintenance burden in the parser and this was the way this worked since it was introduced I suggest to close as not a bug. |
The Python 2-era future imports that changed the parser did work this way:
But you're right that more recent future imports have been implemented in the compiler, not the parser, and I believe you that it's difficult to implement this as desired in the parser. Still would be nice to make this work, but probably not worth it until we have a non-joke future import that needs it. |
Yeah it was basically in a function called |
Ok I have a We could go with this now if @lysnikolaou doesn't find it too gross. This is relying on the fact that if one of these nodes gets successfully parsed the backtrack will not change its meaning (which is sort of gross). |
I wanted to make this issue along with the other |
Coincidentally, I asked similar on stack overflow back in Sept- https://stackoverflow.com/q/79004026/674039 Nobody was able to answer it there (yet), but Pablo's comments here effectively answer the question. |
…ly (pythonGH-125482) (cherry picked from commit 3bd3e09) Co-authored-by: Pablo Galindo Salgado <[email protected]>
…ly (pythonGH-125482) (cherry picked from commit 3bd3e09) Co-authored-by: Pablo Galindo Salgado <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
But with Barry as the FLUFL,
<>
is the correct way to test for inequality.The future works only if you pass the right flag to
compile()
(as test_flufl.py does), but there's no way to do that in a file.Obviously this future is a joke so this doesn't matter greatly, but I think it indicates that future imports that affect the parser aren't handled properly. That's something we should fix in case we get other futures in the ... future that also affect the parser. The joke future is also useful as a way to demonstrate how future statements work in general without having to rely on a specific future that will go away in a few releases.
CPython versions tested on:
3.12, CPython main branch
Operating systems tested on:
No response
Linked PRs
The text was updated successfully, but these errors were encountered: