[New-bugs-announce] [issue36911] ast.parse outputs ast.Strs which do not differentiate between the ASCII codepoint 12 (literal new line) and the ASCII codepoints 134 and 156 ("\n")
Amber Brown
report at bugs.python.org
Mon May 13 22:02:23 EDT 2019
New submission from Amber Brown <hawkowl at atleastfornow.net>:
reproducing case:
file.py:
```
"""
Hello \n blah.
"""
```
And then in a REPL (2.7 or 3+):
```
>>> import ast
>>> f = ast.parse(open("test.py", 'rb').read())
>>> f
<_ast.Module object at 0x7f609d0a4d68>
>>> f.body[0]
<_ast.Expr object at 0x7f609d0a4e10>
>>> f.body[0].value
<_ast.Str object at 0x7f609d02b780>
>>> f.body[0].value.s
'\nHello \n blah.\n'
>>> repr(f.body[0].value.s)
"'\\nHello \\n blah.\\n'"
```
Expected behaviour:
```
>>> repr(f.body[0].value.s)
"'\\nHello \\\\n blah.\\n'"
```
----------
components: Library (Lib)
messages: 342417
nosy: hawkowl
priority: normal
severity: normal
status: open
title: ast.parse outputs ast.Strs which do not differentiate between the ASCII codepoint 12 (literal new line) and the ASCII codepoints 134 and 156 ("\n")
versions: Python 2.7, Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36911>
_______________________________________
More information about the New-bugs-announce
mailing list