REPL: Don't print the line that produced a `SyntaxWarning` if only a single line was given as input
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Feature or enhancement
Bug description:
The old REPL had this behaviour:
~/dev/cpython (main)⚡ % PYTHON_BASIC_REPL=1 ./python.exe
Python 3.14.0a0 (heads/main:4606eff0aa, Jul 23 2024, 20:19:47) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> False is 0
<stdin>-0:1: SyntaxWarning: "is" with 'int' literal. Did you mean "=="?
False
The new one has this behaviour:
~/dev/cpython (main)⚡ % ./python.exe
Python 3.14.0a0 (heads/main:4606eff0aa, Jul 23 2024, 20:19:47) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 0 is False
<python-input-0>:1: SyntaxWarning: "is" with 'int' literal. Did you mean "=="?
0 is False
False
The new behaviour seems better if you've given a multiline function as input since, unlike the old REPL, it tells you exactly which line of code produced the warning:
~/dev/cpython (main)⚡ % ./python.exe
Python 3.14.0a0 (heads/main:4606eff0aa, Jul 23 2024, 20:19:47) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo():
... 0 is False
... 3 == 4
...
<python-input-0>:2: SyntaxWarning: "is" with 'int' literal. Did you mean "=="?
0 is False
...but it feels a bit redundant if, as in my first example, only a single line was entered as input. It took me a little while to figure out why the REPL was just printing the line I had typed back at me.
CPython versions tested on:
CPython main branch
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.
Línea de trabajo
Comienza reproduciendo los ejemplos de una sola línea y multilínea en la nueva CPython REPL y compara su salida de SyntaxWarning. Lee la ruta de visualización de advertencias de la REPL y, después, haz que el caso de una sola línea omita el código fuente repetido, preservando la línea de código fuente para la entrada multilínea; verifica ambos comportamientos con pruebas de REPL específicas.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- cli
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100