Message309901
The following code (simplified from a real example) triggers an unexpected TypeError:
@dataclass
class PrioritizedItem:
priority: 'int'
def __eq__(self, other):
return self.priority == other.priority
This code gives the following trackback:
Traceback (most recent call last):
File "/Users/raymond/Documents/tmp16.py", line 16, in <module>
@dataclass
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 598, in dataclass
return wrap(_cls)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 590, in wrap
return _process_class(cls, repr, eq, order, hash, init, frozen)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 539, in _process_class
_set_attribute(cls, '__hash__', None)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dataclasses.py", line 444, in _set_attribute
raise TypeError(f'Cannot overwrite attribute {name} '
TypeError: Cannot overwrite attribute __hash__ in PrioritizedItem |
|
Date |
User |
Action |
Args |
2018-01-13 21:26:23 | rhettinger | set | recipients:
+ rhettinger, eric.smith |
2018-01-13 21:26:23 | rhettinger | set | messageid: <1515878783.18.0.467229070634.issue32546@psf.upfronthosting.co.za> |
2018-01-13 21:26:23 | rhettinger | link | issue32546 messages |
2018-01-13 21:26:22 | rhettinger | create | |
|