Skip to content

Unexpected behavior in f-strings with nested quotes #127428

@BertLindeman

Description

@BertLindeman

Bug report

Bug description:

This "program" prints run

print(f"{"run"}")

This syntax is invalid as the nested double quotes should conflict with the outer ones.
It is expected to raise a SyntaxError.

This program (the same, but just without the 'f', so no f-string)

print("{"run"}")

reports:

  File "/home/bert/py/pybricks/issue/issue_1954_fstring_problem_syntax_simple_OK.py", line 2
    print("{"run"}")
          ^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

CPython versions tested on:

3.10, 3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions