-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
topic-argument-clinictopic-unicodetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
Consider the following:
import unicodedata
unicodedata.name('')
unicodedata.name('a')
unicodedata.name('\x00')Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
unicodedata.name('')
TypeError: name() argument 1 must be a unicode character, not str
'LATIN SMALL LETTER A'
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
unicodedata.name('\x00')
ValueError: no such name
It seems there are two issues here:
- unicodedata.name() and possibly other
unicodedatamethods can have an undocumented TypeError exception. https://docs.python.org/3/library/unicodedata.html - The
TypeErroron an empty string doesn't really seem accurate, since the function can still take other string values of the samestrtype.
Either TypeError should be mentioned in documentation, or the handling of empty strings should be fixed in the library to return a ValueError instead.
CPython versions tested on:
3.12
Operating systems tested on:
Windows, Other
Linked PRs
Metadata
Metadata
Assignees
Labels
topic-argument-clinictopic-unicodetype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error