mirror of
https://github.com/python/cpython.git
synced 2024-11-21 12:59:38 +01:00
gh-125008: Fix tokenize.untokenize
roundtrip for \n{{
(#125013)
This commit is contained in:
parent
39c859f6ff
commit
db23b8bb13
@ -1919,6 +1919,26 @@ class TestRoundtrip(TestCase):
|
||||
self.check_roundtrip(r"f'\\\\N{{'")
|
||||
self.check_roundtrip(r"f'\\\\\\N{{'")
|
||||
self.check_roundtrip(r"f'\\\\\\\\N{{'")
|
||||
|
||||
self.check_roundtrip(r"f'\n{{foo}}'")
|
||||
self.check_roundtrip(r"f'\\n{{foo}}'")
|
||||
self.check_roundtrip(r"f'\\\n{{foo}}'")
|
||||
self.check_roundtrip(r"f'\\\\n{{foo}}'")
|
||||
|
||||
self.check_roundtrip(r"f'\t{{foo}}'")
|
||||
self.check_roundtrip(r"f'\\t{{foo}}'")
|
||||
self.check_roundtrip(r"f'\\\t{{foo}}'")
|
||||
self.check_roundtrip(r"f'\\\\t{{foo}}'")
|
||||
|
||||
self.check_roundtrip(r"rf'\t{{foo}}'")
|
||||
self.check_roundtrip(r"rf'\\t{{foo}}'")
|
||||
self.check_roundtrip(r"rf'\\\t{{foo}}'")
|
||||
self.check_roundtrip(r"rf'\\\\t{{foo}}'")
|
||||
|
||||
self.check_roundtrip(r"rf'\{{foo}}'")
|
||||
self.check_roundtrip(r"f'\\{{foo}}'")
|
||||
self.check_roundtrip(r"rf'\\\{{foo}}'")
|
||||
self.check_roundtrip(r"f'\\\\{{foo}}'")
|
||||
cases = [
|
||||
"""
|
||||
if 1:
|
||||
|
@ -200,7 +200,7 @@ class Untokenizer:
|
||||
characters[-2::-1]
|
||||
)
|
||||
)
|
||||
if n_backslashes % 2 == 0:
|
||||
if n_backslashes % 2 == 0 or characters[-1] != "N":
|
||||
characters.append(character)
|
||||
else:
|
||||
consume_until_next_bracket = True
|
||||
|
@ -0,0 +1,2 @@
|
||||
Fix :func:`tokenize.untokenize` producing invalid syntax for
|
||||
double braces preceded by certain escape characters.
|
Loading…
Reference in New Issue
Block a user