05.08.19 07:22, raymond.hettin...@gmail.com пише:
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 do not think there is such intention. I think this warning can be kept
for a long time.
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.
Since the bytecode is cached, the warning in a third-party code is
emitted at most once: when you install a package or when use it the
first time. The warning in your code is emitted every time when you
change it, until you fix it.
In contrary, other deprecation warnings (for example a one about
importing Mapping from collections) is emitted on every run.
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)?
Yes, because it is very likely that there is something like '\arrow' or
'\newline' in the same string literal or in other string literals in the
same file.
I follow for fixes of incompatibilities with new Python versions in
third-party projects, and it looks to me, that in many (if not most)
cases a warning about invalid escape sequences exposes a real bug. So
there is a real benefit from such warnings.
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?
The only character which must be escaped is a backslash. And a quote if
it happens to match a quote used for creating a string literal. It is a
simple rule.
Do we really need to reject ASCII art in docstrings: ` \-------> special case'?
Do we reject ASCII art like '\xxx/'? A backslash should be escaped,
otherwise use raw string literals.
_______________________________________________
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/YPZX7MJSGIOH7EZ2VVPIOA75GUPVUYIN/