Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 28 |
Nodes: | 6 (0 / 6) |
Uptime: | 42:55:21 |
Calls: | 422 |
Calls today: | 1 |
Files: | 1,024 |
Messages: | 90,175 |
A "more formal specification" can be found in, maybe (if I found
the right place), the function definition "_PyBytes_DecodeEscape"
in the source file "Objects\bytesobject.c":
Also, it appears that the change linked above is a lie:
Also, it appears that the change linked above is a lie:
https://docs.python.org/3/reference/lexical_analysis.html#grammar-token-python-grammar-longstringitem
According to the grammar, any character can follow backslash in a
valid Python program. The warning / error raised by this code should
not be a syntax error / warning because the syntax is correct.
Then it just means that the grammar lies.
The two claims are mutually exclusive, so either one is a lie or the
other or both.
My comment was more of an irony really. It's plenty obvious that the
grammar is a lie. The reason is that it's tedious to put the actual
intender rules into the grammar, and so whoever wrote the grammar
decided to cut corners. But, the grammar is supposed to be the
authoritative source for how the language is parsed,
that's why even though it's clear that the grammar is a lie, blaming
whoever doesn't follow it makes it ironic.
In other words, the grammar author didn't put enough effort into
making grammar actually work,
but seeing how many other things are done in Python, this is not an exception. It would've been strange to have it done properly when
"properly" means doing copious amounts of tedious work.
The point is that the error is wrong.
It cannot be a syntax error and at the same time the program compiles.
Read the associate release note.
In a future Python version, SyntaxError will
eventually be raised, instead of SyntaxWarning. (Contributed by Victor Stinner in gh-98401.)
Also, it appears that the change linked above is a lie:
https://docs.python.org/3/reference/lexical_analysis.html#grammar-token-python-grammar-longstringitem
According to the grammar, any character can follow backslash in a
valid Python program. The warning / error raised by this code should
not be a syntax error / warning because the syntax is correct.
... """\hello"""def f():
hif()
On Thu, May 8, 2025 at 7:54 AM Left Right <olegsivokon@gmail.com> wrote:
I think it could be this:
A backslash-character pair that is not a valid escape sequence now
generates a SyntaxWarning, instead of DeprecationWarning. For example,
re.compile("\d+\.\d+") now emits a SyntaxWarning ("\d" is an invalid
escape sequence, use raw strings for regular expression:
re.compile(r"\d+\.\d+")). In a future Python version, SyntaxError will
eventually be raised, instead of SyntaxWarning. (Contributed by Victor
Stinner in gh-98401.)
Found in:
https://docs.python.org/3/whatsnew/3.12.html#other-language-changes
It's not supposed to crash your program though. If the program crashes
because of it, it's a bug in Python.
On Thu, May 8, 2025 at 7:00 AM Bob van der Poel via Python-list
<python-list@python.org> wrote:
Did something change in python buggering up my use of a "\ " sequence in a >>> triple quoted string?
I have yet to go through my archive on the program, but I tried to run it >>> today and it crashed quite spectacularly when it hit a """ .... """ line >>> being used as a comment at the top of a function. I changed the "\" to a >>> "/" and all is well now.
--
**** Listen to my FREE CD at http://www.mellowood.ca/music/cedars ****
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bob@mellowood.ca
WWW: http://www.mellowood.ca
--
https://mail.python.org/mailman/listinfo/python-list