classification
Title: DeprecationWarning not reported for invalid escape sequences
Type: Stage: resolved
Components: Interpreter Core Versions: Python 3.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Improve the warning message for invalid escape sequences
View: 28128
Assigned To: Nosy List: Sergey.Kirpichev, serhiy.storchaka
Priority: normal Keywords:

Created on 2016-10-04 09:00 by Sergey.Kirpichev, last changed 2016-10-04 09:06 by serhiy.storchaka. This issue is now closed.

Messages (2)
msg278020 - (view) Author: Sergey B Kirpichev (Sergey.Kirpichev) * Date: 2016-10-04 09:00
We know from release notes, that "A backslash-character pair that is not a valid escape sequence now generates a DeprecationWarning".  Sometimes it's true:
$ python -W error
Python 3.6.0b1+ (default, Oct  4 2016, 08:47:51) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> "xxx" != "hello \world"
DeprecationWarning: invalid escape sequence '\w'

But shouldn't DeprecationWarning be in the following case as well?

$ cat a.py 
def f(s):
    return s != "hello \world"
$ cat b.py 
import a
print(a.f("xxx"))
$ python b.py 
True
$ python -W error b.py 
True
msg278023 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-10-04 09:06
See issue28128.

A warning should be emitted when you compile the code, but it shouldn't be emitted when you import compiled module.
History
Date User Action Args
2016-10-04 09:06:49serhiy.storchakasetstatus: open -> closed

superseder: Improve the warning message for invalid escape sequences

nosy: + serhiy.storchaka
messages: + msg278023
resolution: duplicate
stage: resolved
2016-10-04 09:00:39Sergey.Kirpichevcreate