[pypy-commit] pypy py3k: kill support for ordering arbitrary objects. It makes test_unordeable_types passing

antocuni noreply at buildbot.pypy.org
Wed Feb 29 23:00:05 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r53027:082078dbfca5
Date: 2012-02-29 14:31 +0100
http://bitbucket.org/pypy/pypy/changeset/082078dbfca5/

Log:	kill support for ordering arbitrary objects. It makes
	test_unordeable_types passing

diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -530,46 +530,12 @@
         return space.wrap(-1)
     if space.is_w(w_obj2, space.w_None):
         return space.wrap(1)
-    if space.is_w(w_typ1, w_typ2):
-        #print "WARNING, comparison by address!"
-        lt = _id_cmpr(space, w_obj1, w_obj2, symbol)
     else:
-        #print "WARNING, comparison by type name!"
-
-        # the CPython rule is to compare type names; numbers are
-        # smaller.  So we compare the types by the following key:
-        #   (not_a_number_flag, type_name, type_id)
-        num1 = number_check(space, w_obj1)
-        num2 = number_check(space, w_obj2)
-        if num1 != num2:
-            lt = num1      # if obj1 is a number, it is Lower Than obj2
-        else:
-            name1 = w_typ1.getname(space, "")
-            name2 = w_typ2.getname(space, "")
-            if name1 != name2:
-                lt = name1 < name2
-            else:
-                lt = _id_cmpr(space, w_typ1, w_typ2, symbol)
-    if lt:
-        return space.wrap(-1)
-    else:
-        return space.wrap(1)
-
-def _id_cmpr(space, w_obj1, w_obj2, symbol):
-    if symbol == "==":
-        return not space.is_w(w_obj1, w_obj2)
-    elif symbol == "!=":
-        return space.is_w(w_obj1, w_obj2)
-    w_id1 = space.id(w_obj1)
-    w_id2 = space.id(w_obj2)
-    return space.is_true(space.lt(w_id1, w_id2))
-
-
-def number_check(space, w_obj):
-    # avoid this as much as possible.  It checks if w_obj "looks like"
-    # it might be a number-ish thing.
-    return (space.lookup(w_obj, '__int__') is not None or
-            space.lookup(w_obj, '__float__') is not None)
+        typename1 = space.type(w_obj1).getname(space)
+        typename2 = space.type(w_obj2).getname(space)
+        raise operationerrfmt(space.w_TypeError,
+                              "unorderable types: %s %s %s",
+                              typename1, symbol, typename2)
 
 
 # regular methods def helpers


More information about the pypy-commit mailing list