Programming Languages
Bug Report
"TypeError: unhashable type" after adding __eq__ to a Python class: __hash__ became None
A small refactor added __eq__ to our Money class so amounts could be compared. Soon a cache decorator and several set operations failed with TypeError: unhashable type: 'Money', because defining __eq__ without __hash__ sets __hash__ to None. How equality and hashing must agree.