[Bug]: tokenize emits a non-existent new line token for empty input
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 74/100
Direzione di ricerca
Inizia eseguendo l’esempio repro.py con GraalPy e CPython, quindi traccia l’implementazione GraalPy di _tokenize.TokenizerIter utilizzata da tokenize.generate_tokens. La correzione è completata quando un input vuoto produce solo l’ENDMARKER compatibile con CPython, con posizioni corrispondenti, mentre i casi esistenti di commenti e newline rimangono corretti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
When using token.generate_tokens() on an empty string, a NL token is returned when no such token exists for CPython. The return token also spans a non-existent length, which caused stubgen-pyx to crash. Only effects "", # ... and "\n" were fine. This caused stubgen-pyx to crash on an otherwise empty file.
Likely occurs in GraalPy's re-implementation of _tokenize.TokenizerIter
Operating system
Linux
CPU architecture
x86_64
GraalPy version
GraalPy 3.13.14 (GraalVM CE Native 25.3.4.1)
JDK version
openjdk 25.0.4 2026-07-21 LTS (Temurin-25.0.4+7)
Context configuration
N/A
Steps to reproduce
# repro.py
import io, tokenize
for tok in tokenize.generate_tokens(io.StringIO("").readline):
print(tok)
$ graalpy repro.py
TokenInfo(type=63 (NL), string='', start=(1, 0), end=(1, 1), line='')
TokenInfo(type=0 (ENDMARKER), string='', start=(2, 0), end=(2, 0), line='')
$ python3.13 repro.py # and python3.14, identical
TokenInfo(type=0 (ENDMARKER), string='', start=(1, 0), end=(1, 0), line='')
Native version
import io, _tokenize
for t in _tokenize.TokenizerIter(io.StringIO("").readline, extra_tokens=True):
print(t)
#GraalPy 3.13.14: (63, '', (1, 0), (1, 1), '') ← phantom NL
# (0, '', (2, 0), (2, 0), '')
#CPython 3.13: (0, '', (1, 0), (1, 0), '')
Expected behavior
Should match the same output as CPython 3.13, and not emit non-existent spans.
Stack trace
N/A
Additional context
N/A
- Lingua principale
- Python
- Stelle
- 1.6k
- Fork
- 155
- Merge medio
- 8h 20m
- PR unite (30g)
- 43
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di oracle/graalpython
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
oracle/graalpython#1105 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
oracle/graalpython#1102 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
oracle/graalpython#1112 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
oracle/graalpython#1111 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
oracle/graalpython#1110 · 1 commento ·
Tutte le issue di oracle/graalpython
Issue simili
-
bug confirmed issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
open-webui/open-webui#30750 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100