Regression in tokenizer handling of `\r`
Aberta
@serhiy-storchaka já está trabalhando nisso.
Desde 30/12/2024.
topic-parser
type-bug
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Avaliação
Esta issue ainda não foi avaliada.