mirror of
https://github.com/python/cpython.git
synced 2025-08-08 19:09:46 +00:00
[3.12] gh-105800: Issue SyntaxWarning in f-strings for invalid escape sequences (GH-105801) (#105806)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
parent
52a2bbdc9d
commit
638c2bacde
3 changed files with 8 additions and 3 deletions
|
@ -907,6 +907,9 @@ x = (
|
|||
with self.assertWarns(DeprecationWarning): # invalid escape sequence
|
||||
value = eval(r"f'\{6*7}'")
|
||||
self.assertEqual(value, '\\42')
|
||||
with self.assertWarns(SyntaxWarning): # invalid escape sequence
|
||||
value = eval(r"f'\g'")
|
||||
self.assertEqual(value, '\\g')
|
||||
self.assertEqual(f'\\{6*7}', '\\42')
|
||||
self.assertEqual(fr'\{6*7}', '\\42')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue