This really is a hairy one.

The current behaviour encourages people to use a single backslash when 
they should be using a double, but that works only sometimes. Should you 
include an escape or not? Sometimes the backslash stays and sometimes it 
disappears:

py> "abc \d \' xyz"
"abc \\d ' xyz"

To be honest, I'm kind of surprised that I haven't seen a bug report for 
the backslash disappearing when followed by a quote.

This behaviour also prevents us from adding new kinds of escape 
sequences in the future without a deprecation period. For example, 
there's a long-missing escape sequence often found in C, \e for ESC, but 
we can't add it now even if we wanted it because it would break code 
that relies on "\e" being the same as "\\e".

So I remain +1 on changing the behaviour.

On the other hand, I see Raymond's point. Having tried it with a few 
contrived modules, I agree that it would be intimidating and annoying 
for many users.

As an educator, Raymond could easily teach people how to silence the 
warnings. But people outside the classroom are going to be hit with 
these warnings too, and many of them are not going to know how to 
silence them or even that it is possible to silence them.

I see Raymond's point about not breaking ASCII art, but I think that 
there are work-arounds for that, using raw strings and string 
concatenation. Besides, its 2019 and we use UTF-8 by default. Unicode 
provides alternative ways to draw ASCII art than pure ASCII:

Raymond's example:
    '\-------> special case'

Unicode:
    '└───────▷ special case'

So I'm coming around to the position that while we should continue with 
the plan to make invalid escape sequences an error, we should slow down 
a bit. This isn't a critical problem that needs to be fixed soonest. 
Let's push everything back one release:

- Keep the SyntaxWarning silent by default for 3.8. That gives us 
another year or more to gently pressure third-party libraries to fix 
their code, and to find ways to encourage developers to run with 
warnings enabled.

- In 3.9, we can try making the warnings visible again.

- And aim to make it an error in 4.0/3.10.



-- 
Steven
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/LNGLOCHOFWKAWW4AI2WYYBIWGJXB3LNY/

Reply via email to