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

Field values must be hashable #49

Closed
dahlia opened this issue Jan 24, 2017 · 1 comment
Closed

Field values must be hashable #49

dahlia opened this issue Jan 24, 2017 · 1 comment
Assignees
Labels

Comments

@dahlia
Copy link
Member

@dahlia dahlia commented Jan 24, 2017

Fields of record or union tag must accept only hashable values. For example, a Python code generated from the following IDL:

record test ({bigint} a);

currently can take values that aren't hashable e.g.:

>>> v = Test(a=frozenset([1, 2, 3]))
>>> hash(v)
-3553164928370265785
>>> v2 = Test(a={1, 2, 3})
>>> hash(v2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/.../test/__init__.py", line 56, in __hash__
    return hash((self.a,))
TypeError: unhashable type: 'set'

Expected behavior would be e.g.:

>>> v = Test(a=frozenset([1, 2, 3]))
>>> hash(v)
-3553164928370265785
>>> v2 = Test(a={1, 2, 3})
Traceback (most recent call last):
  ...
TypeError: a must be hashable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants