Regression in tokenizer handling of `\r`
Abierto
@serhiy-storchaka ya está trabajando en esto.
Desde el 30/12/2024.
topic-parser
type-bug
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug report
Bug description:
Python 3.12 onwards we get a weird \r} token when trying to parse a file just containing '{\r}':
$ printf '{\r}' | python3.11 -m tokenize
1,0-1,1: OP '{'
1,1-1,2: ERRORTOKEN '\r'
1,2-1,3: OP '}'
1,3-1,4: NEWLINE ''
2,0-2,0: ENDMARKER ''
$ printf '{\r}' | python3.12 -m tokenize
1,0-1,1: OP '{'
1,1-1,3: OP '\r}'
1,3-1,4: NEWLINE ''
2,0-2,0: ENDMARKER ''
Weirdly, AST generation passes just fine in both cases:
$ printf '{\r}' | python3.11 -m ast
Module(
body=[
Expr(
value=Dict(keys=[], values=[]))],
type_ignores=[])
$ printf '{\r}' | python3.12 -m ast
Module(
body=[
Expr(
value=Dict(keys=[], values=[]))],
type_ignores=[])
Expected behaviour
I'd expect the \r to yield a NL 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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.