[New-bugs-announce] [issue37182] ast - handling new line inside a string

Ilya Kamenshchikov report at bugs.python.org
Thu Jun 6 15:41:45 EDT 2019


New submission from Ilya Kamenshchikov <ikamenshchikov at gmail.com>:

parsing two different strings produces identical ast.Str nodes:

import ast

txt1 = '"""\\n"""'
txt2 = '"""\n"""'

tree1 = ast.parse(txt1)
tree2 = ast.parse(txt2)

print(tree1.body[0].value.s == tree2.body[0].value.s)
print(bytes(tree1.body[0].value.s, encoding='utf-8'))
print(bytes(tree2.body[0].value.s, encoding='utf-8'))

>>> True
>>> b'\n'
>>> b'\n'

Expected result: I should be able to distinguish between the nodes created from two different strings.

----------
components: Library (Lib)
messages: 344861
nosy: Ilya Kamenshchikov
priority: normal
severity: normal
status: open
title: ast - handling new line inside a string
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37182>
_______________________________________


More information about the New-bugs-announce mailing list