REPL: Don't print the line that produced a `SyntaxWarning` if only a single line was given as input
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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
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.
Direção de pesquisa
Comece reproduzindo os exemplos de uma linha e de várias linhas no novo CPython REPL e compare a saída de SyntaxWarning. Leia o caminho de exibição de avisos do REPL e, em seguida, faça com que o caso de uma linha omita o código-fonte ecoado, preservando a linha de código-fonte para entradas de várias linhas; verifique ambos os comportamentos com testes de REPL focados.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- cli
- Tipo de issue
- Funcionalidade
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 45/100