On 05.08.2019 7:22, raymond.hettinger@gmail.com wrote:
We should revisit what we want to do (if anything) about invalid escape sequences.
For Python 3.8, the DeprecationWarning was converted to a SyntaxWarning which is visible by default. The intention is to make it a SyntaxError in Python 3.9.
I don't see a problem with the DeprecationWarning approach. It's our standard procedure for removing features. Just make it an error in a later release -- whoever didn't heed the warning can't say we didn't warn them well in advance that this will stop working in the future. It doesn't matter if this was a "perfectly working code": we change Python over time and what worked in the past may stop in the future. That's not something unexpected and we don't guarantee compatibility between minor releases. It looks like either the core team has no unifying vision on what the deprecation process is and/or what each warning is for, or that this was a user experience experiment and Raymond's complaint is a part of its feedback (so the Mysterious Omniscient Council is probably going to incorporate it into other feedback and decide what they want to do next).
This once seemed like a reasonable and innocuous idea to me; however, I've been using the 3.8 beta heavily for a month and no longer think it is a good idea. The warning crops up frequently, often due to third-party packages (such as docutils and bottle) that users can't easily do anything about. And during live demos and student workshops, it is especially distracting.
I now think our cure is worse than the disease. If code currently has a non-raw string with '\latex', do we really need Python to yelp about it (for 3.8) or reject it entirely (for 3.9)? If someone can't remember exactly which special characters need to be escaped, do we really need to stop them in their tracks during a data analysis session? Do we really need to reject ASCII art in docstrings: ` \-------> special case'?
IIRC, the original problem to be solved was false positives rather than false negatives: filename = '..\training\new_memo.doc'. The warnings and errors don't do (and likely can't do) anything about this.
If Python 3.8 goes out as-is, we may be punching our users in the nose and getting almost no gain from it. ISTM this is a job best left for linters. For a very long time, Python has been accepting the likes of 'more \latex markup' and has been silently converting it to 'more \\latex markup'. I now think it should remain that way. This issue in the 3.8 beta releases has been an almost daily annoyance for me and my customers. Depending on how you use Python, this may not affect you or it may arise multiple times per day.
Raymond
P.S. Before responding, it would be a useful exercise to think for a moment about whether you remember exactly which characters must be escaped or whether you habitually put in an extra backslash when you aren't sure. Then see: https://bugs.python.org/issue32912
I use raw strings whenever I have literals with backslashes. Very rarely, I need to insert \n-as-newline -- which I do into a regular string. Since the first one appears in regexes and parameters that are Windows paths and the second one in output messages, they do not intersect.
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@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/ZX2JLOZD...
-- Regards, Ivan