This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yan12125
Recipients martin.panter, r.david.murray, serhiy.storchaka, yan12125
Date 2016-09-13.15:10:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In issue27364, invalid escape sequences in string literals are deprecated. Currently the deprecation message is not so useful when fixing lots of files in one or more large projects. For example, I have two files and

import bar


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

My idea is that the warning message can be improved to provide more information. In it's proposed to let a linter check such misuses. It's useful within a single project. For a project that depends on lots of external projects, a linter is not enough. Things are worse when __import__, imp or importlib are involved, or sys.path is modified. I have to either add some codes or use a debugger to show which module is imported.

For above reasons, I propose to add at least the filename and the line number to the warning message. For example:

$ ./python -W error
Traceback (most recent call last):
  File "", line 1, in <module>
    import bar
  File "/home/yen/Projects/cpython/build/", line 1
SyntaxError: (deprecated usage) invalid escape sequence '\d'

With that I can know which file or project I should blame.

Added some of reviewers from issue27364 to nosy list.
Date User Action Args
2016-09-13 15:10:24yan12125setrecipients: + yan12125, r.david.murray, martin.panter, serhiy.storchaka
2016-09-13 15:10:24yan12125setmessageid: <>
2016-09-13 15:10:24yan12125linkissue28128 messages
2016-09-13 15:10:23yan12125create