tomli
tomli copied to clipboard
Incorrect error message
I ran across an incorrect error message while using tomli.loads
. See the snippet below
import tomli
>>> tomli_str = b'test="a"'
>>> tomli.loads(tomli_str)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "venv\lib\site-packages\tomli\_parser.py", line 74, in loads
src = __s.replace("\r\n", "\n")
TypeError: a bytes-like object is required, not 'str'
Note the actual text of of the type error. It indicates it wants "a bytes-like object is required, not 'str'
". Except it was passed a bytes like object and consulting the documentation loads
actually wants a str
object. So error message text is wrong and in fact opposite of what the function actually wants.
I generated this error using tomli 2.0.1