mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-128016: Improved invalid escape sequence warning message (#128020)
This commit is contained in:
parent
40a4d88a14
commit
8d8b854824
9 changed files with 63 additions and 25 deletions
|
@ -651,7 +651,9 @@ class CosmeticTestCase(ASTTestCase):
|
|||
|
||||
def test_backslash_in_format_spec(self):
|
||||
import re
|
||||
msg = re.escape("invalid escape sequence '\\ '")
|
||||
msg = re.escape('"\\ " is an invalid escape sequence. '
|
||||
'Such sequences will not work in the future. '
|
||||
'Did you mean "\\\\ "? A raw string is also an option.')
|
||||
with self.assertWarnsRegex(SyntaxWarning, msg):
|
||||
self.check_ast_roundtrip("""f"{x:\\ }" """)
|
||||
self.check_ast_roundtrip("""f"{x:\\n}" """)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue