Lysandros Nikolaou <[email protected]> added the comment:
This is limited to cases where the line continuation character is on an
otherwise empty line. For example this works correctly:
$ cat t.py
print("hello world")
print("hello world 2") \
print("hello world 3")
$ ./python.exe t.py
hello world
hello world 2
hello world 3
The actual problem is at the tokenizer level, where a line with only a
continuation character is not considered an empty line and thus two NEWLINE
tokens get emitted, one after the other. The old parser was somehow working
around this, probably by having this in the grammar:
file_input: (NEWLINE | stmt)* ENDMARKER
The PEG parser OTOH does not allow this.
The question now is, is it reasonable to change the tokenizer to consider a
lone backslash an empty line? Do you also consider this a bug? Or should we
change the new parser?
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40847>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com