Skip to content

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

@pablogsal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions