[issue28128] Improve the warning message for invalid escape sequences

Chi Hsuan Yen report at bugs.python.org
Mon Oct 31 11:31:38 EDT 2016


Chi Hsuan Yen added the comment:

The error message is much better now, thanks you all!

Seems the ^ pointer is not always correct. For example, in the function scope it's correct:

$ cat test.py 
def foo():
    s = 'C:\Program Files\Microsoft'

$ python3.7 -W error test.py
  File "test.py", line 2
    s = 'C:\Program Files\Microsoft'
           ^
SyntaxError: invalid escape sequence \P

On the other hand, top-level literals confuses the pointer:

$ cat test.py               
s = 'C:\Program Files\Microsoft'

$ python3.7 -W error test.py
  File "test.py", line 1
    s = 'C:\Program Files\Microsoft'
       ^
SyntaxError: invalid escape sequence \P

Is that expected?

Using 259745f9a1e4 on Arch Linux 64-bit

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28128>
_______________________________________


More information about the Python-bugs-list mailing list