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 — Empty unclosed f-string does not directly raise a SyntaxError in the REPL · Issue #103727 · python/cpython

Empty unclosed f-string does not directly raise a SyntaxError in the REPL #103727

New issue
Copy link
New issue
Copy link
Closed
Closed
Empty unclosed f-string does not directly raise a SyntaxError in the REPL#103727
Copy link
Assignees
lysnikolaou
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@lysnikolaou
lysnikolaou
opened on Apr 23, 2023
Issue body actions

Bug report

This is another bug introduced in 1ef61cf. When typing an empty single-quoted unclosed f-string in the REPL, another line is added and input is expected, before a SyntaxError is raised.

Before 1ef61cf:

❯ ./python.exe 
Python 3.12.0a7+ (tags/v3.12.0a7-153-ga6b07b5a34:a6b07b5a34, Apr 23 2023, 13:18:40) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> f'
  File "<stdin>", line 1
    f'
    ^
SyntaxError: unterminated string literal (detected at line 1)

Current main:

❯ ./python.exe 
Python 3.12.0a7+ (heads/main:05b3ce7339, Apr 23 2023, 13:26:24) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> f"
... 
  File "<stdin>", line 1
    f"
    ^
SyntaxError: unterminated f-string literal (detected at line 2)
>>> f"
... asdnc
  File "<stdin>", line 1
    f"
    ^
SyntaxError: unterminated f-string literal (detected at line 2)
>>> f"
... asdasd"
  File "<stdin>", line 1
    f"
    ^
SyntaxError: unterminated f-string literal (detected at line 2)

Linked PRs

  • GH-103727: Avoid advancing tokenizer too far in f-string mode #103775

Activity

  1. lysnikolaou
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Apr 23, 2023
  2. lysnikolaou
    self-assigned this
    on Apr 23, 2023
  3. terryjreedy commented on Apr 23, 2023

    @terryjreedy
    terryjreedy
    on Apr 23, 2023
    Member
    More actions

    In IDLE, which uses code.interactive_interpreter, which ultimately uses codeop._maybe_compile, I get 'SyntaxError: incomplete input' in installed 3.12.0a7 and the new message at line 1 in fresh repository 3.12.0a7+.

  4. lysnikolaou commented on Apr 23, 2023

    @lysnikolaou
    lysnikolaou
    on Apr 23, 2023
    MemberAuthor
    More actions

    codeop._maybe_compile uses compile, which doesn't encounter the problem mentioned here.

    It's got to do with the interactive mode, where we advance the tokenizer far enough (to backup again afterwards) that a newline character alone is not enough for the syntax error to be emitted directly.

  5. lysnikolaou
    added 2 commits that reference this issue on Apr 24, 2023

    pythonGH-103727: Avoid advancing tokenizer too far in f-string mode

    8e4f6a3

    GH-103727: Avoid advancing tokenizer too far in f-string mode (GH-103775

    cb157a1
  6. carljm
    added 2 commits that reference this issue on Apr 24, 2023

    Merge branch 'main' into superopt

    19b8025

    Merge branch 'superopt' into superopt_spec

    1972ca4
  7. lysnikolaou commented on Apr 26, 2023

    @lysnikolaou
    lysnikolaou
    on Apr 26, 2023
    MemberAuthor
    More actions

    Resolved in #103775.

  8. lysnikolaou
    closed this as completedon Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @lysnikolaou
    lysnikolaou

Labels

type-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.