[pypy-svn] r77761 - in pypy/branch/fast-forward/pypy/objspace/std: . test
afa at codespeak.net
afa at codespeak.net
Sun Oct 10 18:39:28 CEST 2010
Author: afa
Date: Sun Oct 10 18:39:24 2010
New Revision: 77761
Modified:
pypy/branch/fast-forward/pypy/objspace/std/test/test_typeobject.py
pypy/branch/fast-forward/pypy/objspace/std/typeobject.py
Log:
Declare an __eq__ slot for type objects.
Later, __lt__ will have to raise a py3k warning.
Modified: pypy/branch/fast-forward/pypy/objspace/std/test/test_typeobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/test/test_typeobject.py (original)
+++ pypy/branch/fast-forward/pypy/objspace/std/test/test_typeobject.py Sun Oct 10 18:39:24 2010
@@ -856,6 +856,22 @@
assert Abc.__name__ == 'Def'
raises(TypeError, "Abc.__name__ = 42")
+ def test_compare(self):
+ class A(object):
+ pass
+ class B(A):
+ pass
+ A.__eq__
+ A.__ne__
+ assert A.__eq__(A)
+ assert not A.__eq__(B)
+ assert A.__ne__(B)
+ assert not A.__ne__(A)
+ assert A == A
+ assert A != B
+ assert not A == B
+ assert not A != A
+
def test_class_variations(self):
class A(object):
pass
Modified: pypy/branch/fast-forward/pypy/objspace/std/typeobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/typeobject.py (original)
+++ pypy/branch/fast-forward/pypy/objspace/std/typeobject.py Sun Oct 10 18:39:24 2010
@@ -790,6 +790,9 @@
w_type.mutated()
w_type.dict_w[name] = w_value
+def eq__Type_Type(space, w_self, w_other):
+ return space.is_(w_self, w_other)
+
def delattr__Type_ANY(space, w_type, w_name):
if w_type.lazyloaders:
w_type._freeze_() # force un-lazification
More information about the Pypy-commit
mailing list