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 -->
Reactions are currently unavailable
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 -->