Skip to content
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

deserialize_meta() unexpectedly fails on None when type is not Optional[T] #97

Open
dahlia opened this issue Jul 28, 2017 · 0 comments
Open
Labels

Comments

@dahlia
Copy link
Member

dahlia commented Jul 28, 2017

The following code is for reproduction:

from nirum.deserialize import deserialize_meta
deserialize_meta(str, None)

We expected it will raise TypeError made by the Nirum runtime library with a nice message, but it fails due to None is passed to str() without validation about None value:

Traceback (most recent call last):
  File "t.py", line 2, in <module>
    deserialize_meta(str, None)
  File "/.../nirum/deserialize.py", line 212, in deserialize_meta
    d = deserialize_primitive(cls, data)
  File "/.../nirum/deserialize.py", line 168, in deserialize_primitive
    raise ValueError("'{}' is not a string.".format(data))
ValueError: 'None' is not a string.
@dahlia dahlia added the bug label Jul 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant