You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
The error message is bad because it is not raised directly by tomli but the bytes.replace method of the unsupported bytes object. Tomli let's it bubble up.
Question to @encukou: Does tomllib (or CPython in general) care about PRs that improve error messages like this?
I ran across an incorrect error message while using
tomli.loads
. See the snippet belowNote 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 documentationloads
actually wants astr
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
The text was updated successfully, but these errors were encountered: