gh-127975: Avoid reusing quote types in ast.unparse if not needed (#1… · python/cpython@8df5193 · GitHub
Skip to content

Commit 8df5193

Browse files
authored
gh-127975: Avoid reusing quote types in ast.unparse if not needed (#127980)
1 parent 95504f4 commit 8df5193

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

Lib/ast.py

Lines changed: 8 additions & 3 deletions

Lib/test/test_unparse.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,13 @@ def test_class_bases_and_keywords(self):
513513
self.check_src_roundtrip("class X(*args, **kwargs):\n pass")
514514

515515
def test_fstrings(self):
516-
self.check_src_roundtrip("f'-{f'*{f'+{f'.{x}.'}+'}*'}-'")
517-
self.check_src_roundtrip("f'\\u2028{'x'}'")
516+
self.check_src_roundtrip('''f\'\'\'-{f"""*{f"+{f'.{x}.'}+"}*"""}-\'\'\'''')
517+
self.check_src_roundtrip('''f\'-{f\'\'\'*{f"""+{f".{f'{x}'}."}+"""}*\'\'\'}-\'''')
518+
self.check_src_roundtrip('''f\'-{f\'*{f\'\'\'+{f""".{f"{f'{x}'}"}."""}+\'\'\'}*\'}-\'''')
519+
self.check_src_roundtrip('''f"\\u2028{'x'}"''')
518520
self.check_src_roundtrip(r"f'{x}\n'")
519-
self.check_src_roundtrip("f'{'\\n'}\\n'")
520-
self.check_src_roundtrip("f'{f'{x}\\n'}\\n'")
521+
self.check_src_roundtrip('''f"{'\\n'}\\n"''')
522+
self.check_src_roundtrip('''f"{f'{x}\\n'}\\n"''')
521523

522524
def test_docstrings(self):
523525
docstrings = (
Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)