Skip to content

umsgpack can't unpack python dicts with tuple keys #10

@ralphjzhang

Description

@ralphjzhang

e.g., for a python dict like:
a = {(1, 2): 3}
it is ok to do umsgpack.pack(a), but get UnhashableKeyException when doing unpack.

The cause is when packing, tuples become lists, but lists can't be a dict key.
But we can safely assume when we see a list as a dict key, it was a tuple at the moment it was serialized. So maybe we can just do

if isinstance(k, list):
k = tuple(k)

and then all the checkings (around line 549)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions