[issue37182] ast - handling new line inside a string

2019-06-06 Thread Eric V. Smith
Eric V. Smith added the comment: There was a recent discussion about this on the bug tracker, but of course now I can't find it. But for an earlier discussion, see issue 25885. The decision was that your expectation that the nodes be distinguishable isn't a design goal of the ast. There's

[issue37182] ast - handling new line inside a string

2019-06-06 Thread Ilya Kamenshchikov
Ilya Kamenshchikov added the comment: Same problem holds for tabs (\\t vs \t). For \\r vs \r, it is even more fun: txt1 = '"""\\r"""' txt2 = '"""\r"""' >>> b'\r' >>> b'\n' -- ___ Python tracker

[issue37182] ast - handling new line inside a string

2019-06-06 Thread Ilya Kamenshchikov
New submission from Ilya Kamenshchikov : 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,