Closed
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
unicodedata
methods can have an undocumented TypeError exception. https://docs.python.org/3/library/unicodedata.html - The
TypeError
on an empty string doesn't really seem accurate, since the function can still take other string values of the samestr
type.
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