Built-in types overriding equality without hash are not marked unhashable
Author: krosciCreated Sep 26, 2026Updated Sep 26, 2026
What happened?
In Python's data model, built-in types that define equality/set-like comparisons without defining __hash__ must have __hash__ set to None, be identified as unhashable (isinstance(..., collections.abc.Hashable) == False), and raise TypeError: unhashable type: '...' when hashed.
In RustPython, several types (dict_keys, dict_items, odict_keys, odict_items, SimpleNamespace, ParamSpecArgs, ParamSpecKwargs, SSLSession) implemented Comparable but omitted unhashable = true, causing them to inherit object.__hash__ and be treated as hashable. Additionally, _queue.SimpleQueue was erroneously marked unhashable = true.
Steps to reproduce
import collections.abc, types
d = {"a": 1}
assert type(d.keys()).__hash__ is None
assert not isinstance(d.keys(), collections.abc.Hashable)
assert types.SimpleNamespace.__hash__ is NoneSource: RustPython/RustPython