GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `barry_as_FLUFL` future flag does not work in new REPL · Issue #124960 · python/cpython

barry_as_FLUFL future flag does not work in new REPL #124960

New issue
Copy link
New issue
Copy link
Closed
Closed
barry_as_FLUFL future flag does not work in new REPL#124960
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sobolevn
sobolevn
opened on Oct 4, 2024
Issue body actions

Bug report

New REPL:

>>> from __future__ import barry_as_FLUFL
>>> 1 <> 2
  File "<python-input-1>", line 1
    1 <> 2
      ^^
SyntaxError: invalid syntax

Old REPL:

>>> from __future__ import barry_as_FLUFL
>>> 1 <> 2
True

I understand that this is just an easter egg :)

Linked PRs

  • gh-124960: Fixed barry_as_FLUFL future flag does not work in new REPL #124999
  • [3.13] gh-124960: Fixed barry_as_FLUFL future flag does not work in new RE… #125475
Reacted by Roman Kitaev, Nicolae Godina, Konstantin Baikov, Ilya Siamionau, Ian Skliarov, Timofey Petelkov, Paul Repin, Alex Waygood, Alexey Sidorov, Thomas Grainger and 24 more

Activity

  1. sobolevn
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    topic-replRelated to the interactive shellRelated to the interactive shell
    on Oct 4, 2024
  2. warsaw commented on Oct 4, 2024

    @warsaw
    warsaw
    on Oct 4, 2024
    Member
    More actions

    Clearly this is a showstopper bug requiring @Yhg1s to delay Python 3.13.0 for another week and another RC! No respect for the FLUFL eh @pablogsal ??? 😭

    Reacted by Barry Warsaw, Lysandros Nikolaou, DmitriyManuilov, sobolevn, neumond, Nazar Kravtsov, Vlad Startsev, Ilya Siamionau, Ivan Kirpichnikov, Alexey Potapov and 25 more
  3. Yhg1s commented on Oct 4, 2024

    @Yhg1s
    Yhg1s
    on Oct 4, 2024
    Member
    More actions

    I can't believe it, just last week @ambv and @pablogsal were complaining about how easter eggs were getting removed, and here they are, organising a coup! Clearly this should be fixed as soon as possible1!!!!

    Footnotes

    1. which means 3.13.1 ↩

    Reacted by Pablo Galindo Salgado, Stanislav Zmiev, sobolevn, Nice Zombies, Hugo van Kemenade, Daniel Hollas, Thomas Grainger, Savannah Ostrowski and Amin Abbasov
  4. nineteendo commented on Oct 5, 2024

    @nineteendo
    nineteendo
    on Oct 5, 2024
    Contributor
    More actions

    Hmm, it looks like it's working in the commit that introduced the new REPL: f27f8c7

    Screenshot 2024-10-05 at 21 52 09
  5. nineteendo commented on Oct 5, 2024

    @nineteendo
    nineteendo
    on Oct 5, 2024
    Contributor
    More actions

    Bisected to a3e4fec.

  6. nineteendo commented on Oct 5, 2024

    @nineteendo
    nineteendo
    on Oct 5, 2024
    Contributor
    More actions

    It's failing at this line:

    cpython/Lib/_pyrepl/simple_interact.py

    Line 86 in a3e4fec

    tree = ast.parse(source)

  7. nineteendo commented on Oct 5, 2024

    @nineteendo
    nineteendo
    on Oct 5, 2024
    Contributor
    More actions

    Note that this is equivalent to:

    tree = compile(source, filename, symbol, ast.PyCF_ONLY_AST)

    Which doesn't use codeop.Compile().

  8. nineteendo commented on Oct 5, 2024

    @nineteendo
    nineteendo
    on Oct 5, 2024
    Contributor
    More actions

    Is this acceptable?

    diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py
    index d65b6d0d627..6e24860d3c8 100644
    --- a/Lib/_pyrepl/simple_interact.py
    +++ b/Lib/_pyrepl/simple_interact.py
    @@ -83,7 +83,7 @@ def showtraceback(self):
     
         def runsource(self, source, filename="<input>", symbol="single"):
             try:
    -            tree = ast.parse(source)
    +            tree = self.compile.compiler(source, filename, symbol, ast.PyCF_ONLY_AST)
             except (OverflowError, SyntaxError, ValueError):
                 self.showsyntaxerror(filename)
                 return False
    diff --git a/Lib/codeop.py b/Lib/codeop.py
    index 6ad60e7f850..8a77075b487 100644
    --- a/Lib/codeop.py
    +++ b/Lib/codeop.py
    @@ -44,6 +44,7 @@
     # Caveat emptor: These flags are undocumented on purpose and depending
     # on their effect outside the standard library is **unsupported**.
     PyCF_DONT_IMPLY_DEDENT = 0x200
    +PyCF_ONLY_AST = 0x400
     PyCF_ALLOW_INCOMPLETE_INPUT = 0x4000
     
     def _maybe_compile(compiler, source, filename, symbol):
    @@ -109,11 +110,13 @@ class Compile:
         def __init__(self):
             self.flags = PyCF_DONT_IMPLY_DEDENT | PyCF_ALLOW_INCOMPLETE_INPUT
     
    -    def __call__(self, source, filename, symbol, **kwargs):
    -        flags = self.flags
    +    def __call__(self, source, filename, symbol, flags=0, **kwargs):
    +        flags |= self.flags
             if kwargs.get('incomplete_input', True) is False:
                 flags &= ~PyCF_DONT_IMPLY_DEDENT
                 flags &= ~PyCF_ALLOW_INCOMPLETE_INPUT
    +        if flags & PyCF_ONLY_AST:
    +            return compile(source, filename, symbol, flags, True)
             codeob = compile(source, filename, symbol, flags, True)
             for feature in _features:
                 if codeob.co_flags & feature.compiler_flag:
    Reacted by Wulian233
  9. pablogsal commented on Oct 6, 2024

    @pablogsal
    pablogsal
    on Oct 6, 2024
    Member
    More actions

    Clearly this is a showstopper bug requiring @Yhg1s to delay Python 3.13.0 for another week and another RC! No respect for the FLUFL eh @pablogsal ??? 😭

    image

    Reacted by sobolevn, Mikhail Efimov, Amin Abbasov and denballakh
  10. nineteendo commented on Oct 9, 2024

    @nineteendo
    nineteendo
    on Oct 9, 2024
    Contributor
    More actions

    There's no specific code in the PR to handle this easter egg, so I think the bug applies to all syntax changing futures. It just so happens this is currently the only future that changes syntax. If it did not exist, it might have been very tedious to figure this out when adding one in the future.

    Edit: but it's worth noting that old futures changed the parser and not compiler.

  11. warsaw commented on Oct 9, 2024

    @warsaw
    warsaw
    on Oct 9, 2024
    Member
    More actions

    barry_as_FLUFL FTW... again! 🤣

    Reacted by Nice Zombies, Hugo van Kemenade and Amin Abbasov
  12. JelleZijlstra commented on Oct 11, 2024

    @JelleZijlstra
    JelleZijlstra
    on Oct 11, 2024
    Member
    More actions

    @nineteendo's code looks reasonable to me; please submit a PR!

    Note that support in the old REPL was also somewhat broken (this is #125331):

    % python3.12
    Python 3.12.4 (main, Jul 24 2024, 15:24:11) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from __future__ import barry_as_FLUFL; print(1 <> 2)
      File "<stdin>", line 1
        from __future__ import barry_as_FLUFL; print(1 <> 2)
                                                       ^^
    SyntaxError: invalid syntax
    >>> from __future__ import barry_as_FLUFL
    >>> print(1 <> 2)
    True
    >>> 
  13. nineteendo commented on Oct 11, 2024

    @nineteendo
    nineteendo
    on Oct 11, 2024
    Contributor
    More actions

    please submit a PR!

    Wulian233 already updated his PR with my patch: #124999.

  14. ambv
    added a commit that references this issue on Oct 14, 2024

    gh-124960: Fixed `barry_as_FLUFL` future flag does not work in new RE…

    6a08a75
  15. nineteendo
    added a commit that references this issue on Oct 14, 2024

    pythongh-124960: Fixed `barry_as_FLUFL` future flag does not work in …

    710d586
  16. ambv
    added a commit that references this issue on Oct 14, 2024

    [3.13] gh-124960: Fixed `barry_as_FLUFL` future flag does not work in…

    d54dbd6
  17. ambv commented on Oct 14, 2024

    @ambv
    ambv
    on Oct 14, 2024
    Contributor
    More actions

    The immediate fix is landed. Keeping this open because of the long-standing bug preventing the future import to work when parsed in one pass with its usage.

    Reacted by Nice Zombies
  18. nineteendo commented on Oct 14, 2024

    @nineteendo
    nineteendo
    on Oct 14, 2024
    Contributor
    More actions

    Jelle has already opened a separate issue for that: #125331, so I would close this one.

  19. ambv commented on Oct 14, 2024

    @ambv
    ambv
    on Oct 14, 2024
    Contributor
    More actions

    Alright, let's do that then. Thanks!

  20. ambv
    closed this as completedon Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixestopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.