New submission from Chi Hsuan Yen: 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 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' My idea is that the warning message can be improved to provide more information. In http://bugs.python.org/issue27364#msg269373 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 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' With that I can know which file or project I should blame. Added some of reviewers from issue27364 to nosy list. ---------- components: Interpreter Core, Library (Lib) messages: 276285 nosy: Chi Hsuan Yen, martin.panter, r.david.murray, serhiy.storchaka priority: normal severity: normal status: open title: Improve the warning message for invalid escape sequences type: enhancement versions: Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28128> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com