Index: Objects/rangeobject.c =================================================================== --- Objects/rangeobject.c (revision 67852) +++ Objects/rangeobject.c (working copy) @@ -295,7 +295,7 @@ 0, /* tp_as_number */ &range_as_sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ - 0, /* tp_hash */ + PyObject_HashNotImplemented, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ Index: Lib/test/test_range.py =================================================================== --- Lib/test/test_range.py (revision 67852) +++ Lib/test/test_range.py (working copy) @@ -71,6 +71,14 @@ self.assertEquals(list(pickle.loads(pickle.dumps(r, proto))), list(r)) + def test_hash(self): + r = range(10) + self.assertRaises(TypeError, hash, range(10)) + + # Issue #4701: still unhashable after attribute access? + r.__hash__ + self.assertRaises(TypeError, hash, range(10)) + def test_main(): test.support.run_unittest(RangeTest)