jsondaora icon indicating copy to clipboard operation
jsondaora copied to clipboard

Fix DeserializationError when passed a dataclasses.Field

Open dutradda opened this issue 5 years ago • 2 comments

The DeserializationError.dict method put the repr of the objects that don't have a __name__ attribute on it's response. This behaviour is wrong and must be changed to only a simple string.

dutradda avatar Sep 27 '19 20:09 dutradda

Hi,

Do you mean the method itself or its return value ?

sgaist avatar Sep 28 '19 18:09 sgaist

Hi!

This behaviour was wrong.

The else must extract a string from the self.args[0].type, but just try to cast to str, then the objects references or __repr__ will be showed instead just the name.

type_name = (
    self.args[0].type.__name__
    if hasattr(self.args[0].type, '__name__')
    else str(self.args[0].type)
)

https://github.com/dutradda/jsondaora/blob/fafe141edc931b4b8d6099a926110f948492b2d3/jsondaora/exceptions.py#L19

dutradda avatar Sep 29 '19 01:09 dutradda