[Bug]: tokenize emits a non-existent new line token for empty input
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 74/100
Línea de trabajo
Comienza ejecutando el ejemplo repro.py con GraalPy y CPython; después, sigue la implementación de GraalPy de _tokenize.TokenizerIter que utiliza tokenize.generate_tokens. La corrección estará terminada cuando una entrada vacía produzca únicamente el ENDMARKER compatible con CPython y con posiciones coincidentes, mientras que los casos existentes de comentarios y saltos de línea sigan siendo correctos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 1.7k
- Forks
- 155
- Merge medio
- 5 h 7 min
- PR fusionados (30 d)
- 45
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la 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.
Más de oracle/graalpython
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
oracle/graalpython#1105 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
oracle/graalpython#1102 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 15/100
oracle/graalpython#1186 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
oracle/graalpython#1185 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
oracle/graalpython#1112 ·
Los mantenedores suelen responder en 1 día
Todos los issues de oracle/graalpython
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Medio día Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Qiskit/qiskit-ibm-runtime#3431 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[Lesson] A compatibility-gate rejection is a verdict, not something to overwrite with --accept-riskAbiertolesson-submission needs-ac pending-review
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Ikalus1988/MisakaNet#2870 ·
Los mantenedores suelen responder en 1 día
-
feature:LinkChecker
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
digitalfabrik/integreat-cms#4594 ·
Los mantenedores suelen responder en 5 días