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

msrest.serialization.Deserializer.deserialize_object() cannot handle subclasses #245

Open
jazelenk opened this issue Jan 27, 2022 · 2 comments

Comments

@jazelenk
Copy link

    def deserialize_object(self, attr, **kwargs):
        ...
        obj_type = type(attr)
        ...
        if obj_type == dict:

The net effect is that when attr is a subclass of dict, the operation raises a TypeError, even though it could be deserialized as a dict.

Changing those if obj_type ==... checks to if isinstance(attr, ... would address this.

@lmazuel
Copy link
Member

lmazuel commented Jan 28, 2022

Could you give me a scenario when this would happen? Deserialization is based on json.loads, and this would never return a subclass of dict, so I assume you use it differently?

@jazelenk
Copy link
Author

Sure, here's a real example: I have a subclass of dict for tags. It verifies that the key names and values are legit for Azure resource tags. When I try to supply this to a call to a begin_create_or_update, I get an exception because it cannot figure out how to serialize the dict subclass. json.dumps() handles this fine, but it blows up in deserialize_object because type != dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants