python / python/cpython

`_pyrepl.input.KeymapTranslator` tests for non-existent Unicode category

Aberta
#123,682 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

stdlib topic-repl type-bug
Linguagem predominante
Python
Estrelas
77.2k
Forks
36k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

Bug report

Bug description:

The implementation of _pyrepl.input.KeymapTranslator has a check for input with Unicode category "C". This code has been present since the initial commit of the new REPL in #111567. However, no such category is ever returned by unicodedata because there is no "C" entry in the list of category names¹

>>> any(unicodedata.category(chr(n)) == "C" for n in range(sys.maxunicode))  # Python 3.12
False

I'm not familiar enough with _pyrepl to know what the implications of this always-false predicate are, but I do know that the block in question is effectively dead code because of it.

I think this is meant to be a .startswith() check for the Other category identified by UAX #​44, i.e. the union of Cc | Cf | Cs | Co | Cn, in line with other usage in _pyrepl.reader. I'll open a PR for that.


¹ the list of category names is hardcoded in makeunicodedata.py rather than derived from UCD, which does define C = Cc | Cf | Cs | Co | Cn in PropertyValueAliases.txt. I don't think there's any version of the unicodedata API that would support returning "C" here, though. Just being a little obsessive.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-123683

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece com Lib/_pyrepl/input.py nas linhas 94-95 e compare o uso relacionado de categorias Unicode em Lib/_pyrepl/reader.py. Verifique o comportamento descrito no relatório e inspecione os testes relevantes de _pyrepl; considera-se concluído quando a implementação e os testes refletirem corretamente o tratamento pretendido das categorias Unicode.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
cli
Tipo de issue
Bug
Dificuldade
2/5
Tempo estimado
1-3 horas
Status de atividade
Estagnada
Clareza
Claramente especificada
Facilidade para iniciantes
20/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.