[pypy-commit] pypy stmgc-c7: hg merge release-2.5.x

arigo noreply at buildbot.pypy.org
Tue Mar 17 11:43:53 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r76430:5ed6e6e35d1f
Date: 2015-03-17 11:42 +0100
http://bitbucket.org/pypy/pypy/changeset/5ed6e6e35d1f/

Log:	hg merge release-2.5.x

diff --git a/pypy/objspace/std/test/test_typeobject.py b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -1165,3 +1165,17 @@
                 return x + 1
         a = A()
         assert a.f(1) == 2
+
+    def test_eq_returns_notimplemented(self):
+        assert type.__eq__(int, 42) is NotImplemented
+        assert type.__ne__(dict, 42) is NotImplemented
+        assert type.__eq__(int, int) is True
+        assert type.__eq__(int, dict) is False
+
+    def test_cmp_on_types(self):
+        class X(type):
+            def __cmp__(self, other):
+                return -1
+        class Y:
+            __metaclass__ = X
+        assert (Y < Y) is True
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -650,9 +650,13 @@
                     "type object '%N' has no attribute %R", self, w_name)
 
     def descr_eq(self, space, w_other):
+        if not isinstance(w_other, W_TypeObject):
+            return space.w_NotImplemented
         return space.is_(self, w_other)
 
     def descr_ne(self, space, w_other):
+        if not isinstance(w_other, W_TypeObject):
+            return space.w_NotImplemented
         return space.newbool(not space.is_w(self, w_other))
 
 


More information about the pypy-commit mailing list