mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-115154: Fix untokenize handling of unicode named literals (#115171)
This commit is contained in:
parent
d504968983
commit
ecf16ee50e
3 changed files with 85 additions and 10 deletions
|
@ -1877,6 +1877,43 @@ class TestRoundtrip(TestCase):
|
|||
" print('Can not import' # comment2\n)"
|
||||
"else: print('Loaded')\n")
|
||||
|
||||
self.check_roundtrip("f'\\N{EXCLAMATION MARK}'")
|
||||
self.check_roundtrip(r"f'\\N{SNAKE}'")
|
||||
self.check_roundtrip(r"f'\\N{{SNAKE}}'")
|
||||
self.check_roundtrip(r"f'\N{SNAKE}'")
|
||||
self.check_roundtrip(r"f'\\\N{SNAKE}'")
|
||||
self.check_roundtrip(r"f'\\\\\N{SNAKE}'")
|
||||
self.check_roundtrip(r"f'\\\\\\\N{SNAKE}'")
|
||||
|
||||
self.check_roundtrip(r"f'\\N{1}'")
|
||||
self.check_roundtrip(r"f'\\\\N{2}'")
|
||||
self.check_roundtrip(r"f'\\\\\\N{3}'")
|
||||
self.check_roundtrip(r"f'\\\\\\\\N{4}'")
|
||||
|
||||
self.check_roundtrip(r"f'\\N{{'")
|
||||
self.check_roundtrip(r"f'\\\\N{{'")
|
||||
self.check_roundtrip(r"f'\\\\\\N{{'")
|
||||
self.check_roundtrip(r"f'\\\\\\\\N{{'")
|
||||
cases = [
|
||||
"""
|
||||
if 1:
|
||||
"foo"
|
||||
"bar"
|
||||
""",
|
||||
"""
|
||||
if 1:
|
||||
("foo"
|
||||
"bar")
|
||||
""",
|
||||
"""
|
||||
if 1:
|
||||
"foo"
|
||||
"bar"
|
||||
""" ]
|
||||
for case in cases:
|
||||
self.check_roundtrip(case)
|
||||
|
||||
|
||||
def test_continuation(self):
|
||||
# Balancing continuation
|
||||
self.check_roundtrip("a = (3,4, \n"
|
||||
|
@ -1911,9 +1948,6 @@ class TestRoundtrip(TestCase):
|
|||
tempdir = os.path.dirname(__file__) or os.curdir
|
||||
testfiles = glob.glob(os.path.join(glob.escape(tempdir), "test*.py"))
|
||||
|
||||
# TODO: Remove this once we can untokenize PEP 701 syntax
|
||||
testfiles.remove(os.path.join(tempdir, "test_fstring.py"))
|
||||
|
||||
if not support.is_resource_enabled("cpu"):
|
||||
testfiles = random.sample(testfiles, 10)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue