summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unparse.py
diff options
context:
space:
mode:
authorCyberSaxosTiGER <cybersaxostiger@gmail.com>2020-05-18 18:41:35 (GMT)
committerGitHub <noreply@github.com>2020-05-18 18:41:35 (GMT)
commitd71a6492dbd5434dfa6a0ad95e3ad98aa690887a (patch)
tree5d356a79c8e84a44ec2944b940b584625e9a6310 /Lib/test/test_unparse.py
parentdc31800f86fbcd40ee616984820b885d8adaa6a7 (diff)
downloadcpython-d71a6492dbd5434dfa6a0ad95e3ad98aa690887a.zip
cpython-d71a6492dbd5434dfa6a0ad95e3ad98aa690887a.tar.gz
cpython-d71a6492dbd5434dfa6a0ad95e3ad98aa690887a.tar.bz2
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>
Diffstat (limited to 'Lib/test/test_unparse.py')
-rw-r--r--Lib/test/test_unparse.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py
index 67dcb1d..6d82872 100644
--- a/Lib/test/test_unparse.py
+++ b/Lib/test/test_unparse.py
@@ -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