mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-38870: correctly escape unprintable characters on ast.unparse (GH-20166)
Unprintable characters such as `\x00` weren't correctly roundtripped due to not using default string repr when generating docstrings. This patch correctly encodes all unprintable characters (except `\n` and `\t`, which are commonly used for formatting, and found unescaped). Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
This commit is contained in:
parent
dc31800f86
commit
d71a6492db
2 changed files with 16 additions and 4 deletions
|
@ -324,7 +324,11 @@ class UnparseTestCase(ASTTestCase):
|
|||
'\\t',
|
||||
'\n',
|
||||
'\\n',
|
||||
'\r\\r\t\\t\n\\n'
|
||||
'\r\\r\t\\t\n\\n',
|
||||
'""">>> content = \"\"\"blabla\"\"\" <<<"""',
|
||||
r'foo\n\x00',
|
||||
'🐍⛎𩸽üéş^\X\BB\N{LONG RIGHTWARDS SQUIGGLE ARROW}'
|
||||
|
||||
)
|
||||
for docstring in docstrings:
|
||||
# check as Module docstrings for easy testing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue