-
Notifications
You must be signed in to change notification settings - Fork 187
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
Clarify "What exactly are you trying to pull?" #59
Comments
Any suggestions on what a better error message would be? if not isinstance(s, basestring):
raise TypeError("Expecting something like a string") Would this be better? |
I'd recommend if not isinstance(s, unicode):
raise TypeError('expected {!r} to be unicode; got {!r}'.format(s, type(s))) |
The code is meant to run on both python2 and python3. For that reason, I need to keep the utf-8 decode attempt. In python3, it will only accept normal (unicode) strings. In python2, it will accept both normal strings and unicode strings. When running on python3, basestring is equal to str. With that in mind, the error message should make sense on both python 2 and 3. |
toml/toml.py
Lines 61 to 62 in df2b2df
It's not a very useful error message if you have to dig into the source to figure out what it means. In this case, a
bytes
was being passed in, which is not permissible in python 3. Better would be to avoidbasestring
at all, as it is basically nonsense. Check forbytes
orunicode
and encode or decode appropriately.The text was updated successfully, but these errors were encountered: