[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-18 Thread Lysandros Nikolaou
Lysandros Nikolaou added the comment: Fixed in GH-20072 and bpo-40612. -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker ___

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-11 Thread Guido van Rossum
Guido van Rossum added the comment: I would carefully think about the meaning of that line and see if there are other permutations, e.g. min(Len(blah), offset - 1) ? It would,be nice to specify what we need here from both parsers and from both code chunks for error printing. --

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-11 Thread Lysandros Nikolaou
Lysandros Nikolaou added the comment: Guido: > I wonder if this is the fix we're looking for? I think this is the most sensible thing to do, yes. I guess, we also have to change both parsers to match this behaviour, right? -- ___ Python tracker

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-08 Thread Guido van Rossum
Guido van Rossum added the comment: @Terry: Thanks for confirming the bug in the old parser. Regarding whether column offsets should be 0-based or 1-based: I agree with Tk, but my hand was forced for SyntaxError: we found that it was already using 1-based offsets and we found

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-08 Thread Terry J. Reedy
Terry J. Reedy added the comment: I verified that 3.8 puts the caret under '|', and agree that this is bug that should be fixed at least in a new version. Other such bugs have been fixed in the past. tk Text widgets have 1-based line numbers and 0-based column numbers. The latter is

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-07 Thread Lysandros Nikolaou
Lysandros Nikolaou added the comment: > Hm, but there the old parser seems at fault: it points to the last space > rather than beyond it? Both parsers seem to have the same behaviour, when parsing files. I just found out that even the new parser points to the `|` if there is not trailing

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-07 Thread Guido van Rossum
Guido van Rossum added the comment: Hm, but there the old parser seems at fault: it points to the last space rather than beyond it? -- ___ Python tracker ___

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-07 Thread Lysandros Nikolaou
Lysandros Nikolaou added the comment: > But if the col_offset points way past the text, what should happen? The > clipping there seems reasonable. Note that if a file is being parsed and not a string the behaviour is this: ╰─ cat -e t.py x = 1 | 2 |$ ╰─ ./python.exe t.py File

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-07 Thread Guido van Rossum
Guido van Rossum added the comment: Aha! So the traceback module does have a difference. First, if the offset points inside the text, there's no difference: >>> raise SyntaxError("message", ("", 1, 4, "text")) Traceback (most recent call last): File "", line 1, in File "", line 1

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-07 Thread Lysandros Nikolaou
Lysandros Nikolaou added the comment: Guido: > I don't understand why the traceback module is implicated. The traceback module is implicated, because it currently does not allow the caret to point to a position after the error line. In format_exception_only there is the following snippet of

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-07 Thread Guido van Rossum
Guido van Rossum added the comment: For example: raise SyntaxError("message", ("", 1, 3, "text")) Traceback (most recent call last): File "", line 1, in File "", line 1 text ^ SyntaxError: message >>> (I can't find docs for the constructor of SyntaxError objects. We should

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-07 Thread Guido van Rossum
Guido van Rossum added the comment: I don't understand why the traceback module is implicated. It just formats the information in the SyntaxError object, same as the builtin printing for syntax errors. The key difference is always in what line/column/text is put in the SyntaxError object by

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-07 Thread Batuhan Taskaya
Change by Batuhan Taskaya : -- nosy: +BTaskaya ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue40546] Inconsistencies between PEG parser and traceback SyntaxErrors

2020-05-07 Thread Lysandros Nikolaou
Change by Lysandros Nikolaou : -- title: Inconsistencies between pegen and traceback SyntaxErrors -> Inconsistencies between PEG parser and traceback SyntaxErrors ___ Python tracker