Skip to content

f-strings do not show warnings about invalid escapes #105800

Description

@pablogsal

In 3.12 and 3.13, f-strings are not warning about invalid escapes that get warnings in real strings. This seems like a bug.

>>> f'\?'
'\\?'
>>> len(f'\?')
2
>>> '\?'
<stdin>:1: SyntaxWarning: invalid escape sequence '\?'
'\\?'

_Originally posted by @terryjreedy in https://github.com/python/cpython/issues/105784#issuecomment-1591828755_
            

<!-- gh-linked-prs -->
### Linked PRs
* gh-105801
* gh-105806
<!-- /gh-linked-prs -->

Activity

  1. added a commit that references this issue on Jun 14, 2023
  2. added a commit that references this issue on Jun 15, 2023
  3. added a commit that references this issue on Jun 15, 2023
  4. pablogsal commented on Jun 15, 2023

    @pablogsal
    MemberAuthor
  5. changed the title [-]f-strings are not warning about invalid escapes[/-] [+]f-strings do not warning about invalid escapes[/+] on Jun 15, 2023
  6. changed the title [-]f-strings do not warning about invalid escapes[/-] [+]f-strings do not show warnings about invalid escapes[/+] on Jun 15, 2023
  7. added a commit that references this issue on Jun 15, 2023
  8. added a commit that references this issue on Jun 15, 2023
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.12only security fixes3.13only security fixes

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions