Author Chi Hsuan Yen
Recipients Chi Hsuan Yen, ebarry, ezio.melotti, gvanrossum, jayvdb, martin.panter, python-dev, r.david.murray, serhiy.storchaka, terry.reedy, vstinner, ztane
Date 2016-09-11.09:35:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473586550.65.0.533717871717.issue27364@psf.upfronthosting.co.za>
In-reply-to
Content
Currently the deprecation message is not so useful when fixing lots of files in a large project. For example, I have two files foo.py and bar.py:

# foo.py
import bar

# bar.py
print('\d')

It gives:
$ python3.6 -W error foo.py
Traceback (most recent call last):
  File "foo.py", line 1, in <module>
    import bar
DeprecationWarning: invalid escape sequence '\d'

Things are worse when __import__, imp or importlib are involved. I have to add some codes to show which module is imported.

It would be better to have at least filenames and line numbers:
$ ./python -W error foo.py
Traceback (most recent call last):
  File "foo.py", line 1, in <module>
    import bar
  File "/home/yen/Projects/cpython/build/bar.py", line 1
    print('\d')
         ^
SyntaxError: (deprecated usage) invalid escape sequence '\d'

I have a naive try that prints more information. Raising SyntaxError may not be a good idea, anyway.
History
Date User Action Args
2016-09-11 09:35:50Chi Hsuan Yensetrecipients: + Chi Hsuan Yen, gvanrossum, terry.reedy, vstinner, ezio.melotti, r.david.murray, python-dev, martin.panter, serhiy.storchaka, ztane, jayvdb, ebarry
2016-09-11 09:35:50Chi Hsuan Yensetmessageid: <1473586550.65.0.533717871717.issue27364@psf.upfronthosting.co.za>
2016-09-11 09:35:50Chi Hsuan Yenlinkissue27364 messages
2016-09-11 09:35:50Chi Hsuan Yencreate