mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
[3.12] gh-112364: Correct unparsing of backslashes and quotes in ast.… (#115782)
[3.12] gh-112364: Correct unparsing of backslashes and quotes in ast.unparse (GH-115696)
(cherry picked from commit 69ab93082d
)
This commit is contained in:
parent
3651c2729a
commit
d2fced7128
3 changed files with 24 additions and 7 deletions
|
@ -649,6 +649,21 @@ class CosmeticTestCase(ASTTestCase):
|
|||
self.check_ast_roundtrip("""f'''""\"''\\'{"\\n\\"'"}''' """)
|
||||
self.check_ast_roundtrip("""f'''""\"''\\'{""\"\\n\\"'''""\" '''\\n'''}''' """)
|
||||
|
||||
def test_backslash_in_format_spec(self):
|
||||
self.check_ast_roundtrip("""f"{x:\\ }" """)
|
||||
self.check_ast_roundtrip("""f"{x:\\\\ }" """)
|
||||
self.check_ast_roundtrip("""f"{x:\\\\\\ }" """)
|
||||
self.check_ast_roundtrip("""f"{x:\\\\\\\\ }" """)
|
||||
|
||||
def test_quote_in_format_spec(self):
|
||||
self.check_ast_roundtrip("""f"{x:'}" """)
|
||||
self.check_ast_roundtrip("""f"{x:\\'}" """)
|
||||
self.check_ast_roundtrip("""f"{x:\\\\'}" """)
|
||||
|
||||
self.check_ast_roundtrip("""f'\\'{x:"}' """)
|
||||
self.check_ast_roundtrip("""f'\\'{x:\\"}' """)
|
||||
self.check_ast_roundtrip("""f'\\'{x:\\\\"}' """)
|
||||
|
||||
|
||||
class ManualASTCreationTestCase(unittest.TestCase):
|
||||
"""Test that AST nodes created without a type_params field unparse correctly."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue