#27309 closed Bug (fixed)
Add CallableBool.__hash__()
Reported by: | Reto Aebersold | Owned by: | nobody |
---|---|---|---|
Component: | Utilities | Version: | 1.10 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
As CallableBool has no hash method, membership test operations for sets do not work:
from django.utils.deprecation import CallableTrue assert CallableTrue in {True} TypeError: unhashable type: 'CallableBool'
Adding a hash method solves this problem:
def __hash__(self): return hash(self.value)
Change History (5)
comment:1 by , 8 years ago
Component: | Uncategorized → Utilities |
---|---|
Description: | modified (diff) |
Type: | Uncategorized → Bug |
comment:2 by , 8 years ago
Description: | modified (diff) |
---|---|
Has patch: | set |
Summary: | Missing Hash function in CallableBool → Add CallableBool.__hash__() |
Triage Stage: | Unreviewed → Ready for checkin |
comment:3 by , 8 years ago
Yes, seems strange. I ran into this issue using Django REST framework. When serializing user.is_authenticated it is runs through this check and fails.
Note:
See TracTickets
for help on using tickets.
It seems a bit odd to have such code, but I suppose it doesn't hurt.