You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would have expected the 2,2-2,3: NEWLINE '\n' case in Python 3.12 to be NL instead, as there is no semantic meaning to that newline. Python 3.11 categorizes that correctly as NL.
The behavior was changed because the tokenize module now uses the C tokenizer. And it turned out that a single CR is not always recognized as a newline separator. I tried to fix this today, but it is not so easy. Starting from the fact that the code is read by lines, but C's fgets() and Python's readline() read to the LF byte (this works for the CRLF newlines, but not for CR).
Bug report
Bug description:
Python 3.12 onwards we get a weird
\r}
token when trying to parse a file just containing'{\r}'
:Weirdly, AST generation passes just fine in both cases:
Expected behaviour
I'd expect the
\r
to yield aNL
instead, and we get a}
OP
as expected.CPython versions tested on:
3.11, 3.12, 3.13, 3.14
Operating systems tested on:
macOS
The text was updated successfully, but these errors were encountered: