[Python-Dev] [python-committers] Enabling depreciation warnings feature code cutoff

Serhiy Storchaka storchaka at gmail.com
Mon Nov 13 05:33:00 EST 2017

12.11.17 03:47, Guido van Rossum пише:
> - In Python 3 code, using `\u` escapes in a b'...' literal gives 
> "DeprecationWarning: invalid escape sequence '\u'"
> In both cases these warnings are currently only generated if you run 
> mypy with these warnings enabled, e.g. `python3 -Wd -m mypy <files>`. 
> But this means that mypy would start generating these by default if 
> those warnings were enabled everywhere by default (per Antoine's 
> preference). And while it's debatable whether they are useful, there 
> should at least be a way to turn them off (e.g. when checking Python 2 
> code that's never going to be ported).. Running mypy in the above way is 
> awkward; mypy would likely have to grow a new flag to control this.

It is hard to determine what category is better for this warnings: 
DeprecationWarning or SyntaxWarning. On one hand, SyntaxWarning looks 
more appropriate since the warning is generated by the Python parser. On 
other hand, numerous warnings can confuse end users of Python 
applications, and DeprecationWarning is silenced by default.

This warning is a special case. When it is converted to an error, it 
becomes a SyntaxError, because the latter contains information about 
location of an invalid escape sequence, and produces better error report 
(containing source line, cursor, etc).

More information about the Python-Dev mailing list