backport change from trunk
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index e9a5057..3616642 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1776,6 +1776,8 @@
 
         # Safety test for __cmp__
         def unsafecmp(a, b):
+            if not hasattr(a.__class__, "__cmp__"):
+                return
             try:
                 a.__class__.__cmp__(a, b)
             except TypeError: