Skip to content

Error parsing Python raw f-string with backslash #1681

@jmd-dk

Description

@jmd-dk

Python(3) code using raw f-strings containing a backslash within escaped braces (i.e. double braces) cannot be parsed. A minimum example is

fr'{{\S'

Some pointers:

  • Works: f'{{\S'.
  • Works: r'{{\S'
  • Works: rf'{{'.
  • Works: rf'\S'.
  • Also do not work: rf'{{\S'.
  • The S is not important, though some character must be there in order for the syntax to be valid.

This might seem like a pretty esoteric case. For me it comes up a lot when writing LaTeX in Matplotlib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lexingarea: changes to individual lexersS-minorseverity: minorT-bugtype: a buggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions