Backport of _abccoll.py by Benjamin Arangueren, issue 1383.
With some changes of my own thrown in (e.g. backport of r58107).
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 9f049ad..342e775 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -86,6 +86,8 @@
         class BadEq(object):
             def __eq__(self, other):
                 raise Exc()
+            def __hash__(self):
+                return 24
 
         d = {}
         d[BadEq()] = 42
@@ -397,6 +399,8 @@
         class BadCmp(object):
             def __eq__(self, other):
                 raise Exc()
+            def __hash__(self):
+                return 42
 
         d1 = {BadCmp(): 1}
         d2 = {1: 1}