[Python-Dev] Emit SyntaxWarning on unrecognized backslash escapes?

Chris Angelico rosuav at gmail.com
Tue Feb 24 14:15:55 CET 2015


On Wed, Feb 25, 2015 at 12:00 AM, Thomas Wouters <thomas at python.org> wrote:
> I do expect there to need to be a much longer deprecation period than one or
> even two releases, though: there is a lot of code that uses the misfeature,
> mostly by accident (not realizing they should be using r'', etc.)

I don't mind how long the deprecation period is, as long as there can
be an option to Python that makes a noisy warning. The mixing of tabs
and spaces needed Python 3.0 to become an error, but "python -tt" is
my go-to solution for anyone using Python 2, tabs set to four spaces,
and an editor that doesn't highlight indentation mismatches. Now,
maybe we can't get this option backported to 2.7 (I'd like to, but I
don't think this is on par with hash randomization!), but we could at
least have Python 3.5 or 3.6 accept an option "python3 -e" to warn on
unrecognized escapes, and (paralleling the others) "-ee" to raise
SyntaxErrors. Eventually, even if the deprecation lasts until Python
4.0 or beyond, we could at least depend on being able to call up the
warnings.

ChrisA


More information about the Python-Dev mailing list