Skip to content

_pyrepl.input.KeymapTranslator tests for non-existent Unicode category #123682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SnoopJ opened this issue Sep 4, 2024 · 0 comments
Open

_pyrepl.input.KeymapTranslator tests for non-existent Unicode category #123682

SnoopJ opened this issue Sep 4, 2024 · 0 comments
Labels
topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@SnoopJ
Copy link
Contributor

SnoopJ commented Sep 4, 2024

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

@SnoopJ SnoopJ added the type-bug An unexpected behavior, bug, or error label Sep 4, 2024
@Eclips4 Eclips4 added the topic-repl Related to the interactive shell label Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants