Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py
index fb1699a..56974b8 100644
--- a/Lib/test/test_hash.py
+++ b/Lib/test/test_hash.py
@@ -1,9 +1,11 @@
 # test the invariant that
 #   iff a==b then hash(a)==hash(b)
 #
+# Also test that hash implementations are inherited as expected
 
 import unittest
 from test import support
+from collections import Hashable
 
 
 class HashEqualityTestCase(unittest.TestCase):
@@ -37,8 +39,74 @@
         self.same_hash(float(0.5), complex(0.5, 0.0))
 
 
+_default_hash = object.__hash__
+class DefaultHash(object): pass
+
+_FIXED_HASH_VALUE = 42
+class FixedHash(object):
+    def __hash__(self):
+        return _FIXED_HASH_VALUE
+
+class OnlyEquality(object):
+    def __eq__(self, other):
+        return self is other
+
+class OnlyInequality(object):
+    def __ne__(self, other):
+        return self is not other
+
+class OnlyCmp(object):
+    def __cmp__(self, other):
+        return cmp(id(self), id(other))
+
+class InheritedHashWithEquality(FixedHash, OnlyEquality): pass
+class InheritedHashWithInequality(FixedHash, OnlyInequality): pass
+class InheritedHashWithCmp(FixedHash, OnlyCmp): pass
+
+class NoHash(object):
+    __hash__ = None
+
+class HashInheritanceTestCase(unittest.TestCase):
+    default_expected = [object(),
+                        DefaultHash(),
+                        OnlyInequality(),
+                       ]
+    fixed_expected = [FixedHash(),
+                      InheritedHashWithEquality(),
+                      InheritedHashWithInequality(),
+                      InheritedHashWithCmp(),
+                      ]
+    error_expected = [NoHash(),
+                      OnlyEquality(),
+                      OnlyCmp(),
+                      ]
+
+    def test_default_hash(self):
+        for obj in self.default_expected:
+            self.assertEqual(hash(obj), _default_hash(obj))
+
+    def test_fixed_hash(self):
+        for obj in self.fixed_expected:
+            self.assertEqual(hash(obj), _FIXED_HASH_VALUE)
+
+    def test_error_hash(self):
+        for obj in self.error_expected:
+            self.assertRaises(TypeError, hash, obj)
+
+    def test_hashable(self):
+        objects = (self.default_expected +
+                   self.fixed_expected)
+        for obj in objects:
+            self.assert_(isinstance(obj, Hashable), repr(obj))
+
+    def test_not_hashable(self):
+        for obj in self.error_expected:
+            self.assertFalse(isinstance(obj, Hashable), repr(obj))
+
+
 def test_main():
-    support.run_unittest(HashEqualityTestCase)
+    support.run_unittest(HashEqualityTestCase,
+                         HashInheritanceTestCase)
 
 
 if __name__ == "__main__":