[issue40612] Make traceback module's formatting of SyntaxError more similar to system formatting

Lysandros Nikolaou report at bugs.python.org
Thu May 14 13:39:46 EDT 2020


Lysandros Nikolaou <lisandrosnik at gmail.com> added the comment:

Agreed on everything.

One thing I don't really understand is if you propose to also strip trailing whitespace. Does "limit the offset to just past the end of the source text" include whitespace or not?

For example, the linked PR does not change this behavior:

➜  cpython git:(pr/20072) ./python
Python 3.9.0a6+ (heads/pr/20072:6df7662ca5, May 14 2020, 20:37:50) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> compile('1 +      ', '<string>', 'exec')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1
    1 +      
             ^
SyntaxError: invalid syntax

Should we clip just past the end of `1 +` here?

----------

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


More information about the Python-bugs-list mailing list