Skip to content

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

@dahlia

Description

@dahlia

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions