[pypy-svn] r49678 - in pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Dec 12 17:07:33 CET 2007
Author: cfbolz
Date: Wed Dec 12 17:07:32 2007
New Revision: 49678
Modified:
pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py
pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py
Log:
zing. inplace methods
Modified: pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py
==============================================================================
--- pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py (original)
+++ pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/interp_classobj.py Wed Dec 12 17:07:32 2007
@@ -433,8 +433,8 @@
unwrap_spec=["self", ObjSpace])
# binary operations that return NotImplemented if they fail
-# e.g. rich comparisons and coerce
-for op in 'eq ne gt lt ge le coerce'.split():
+# e.g. rich comparisons, coerce and inplace ops
+for op in 'eq ne gt lt ge le coerce imod iand ipow itruediv ilshift ixor irshift ifloordiv idiv isub imul iadd ior'.split():
specialname = "__%s__" % (op, )
# fool the gateway logic by giving it a real unbound method
meth = new.instancemethod(
Modified: pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py
==============================================================================
--- pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py (original)
+++ pypy/branch/interplevel-oldstyle-classes/pypy/module/__builtin__/test/test_classobj.py Wed Dec 12 17:07:32 2007
@@ -435,3 +435,18 @@
raises(TypeError, "a + 1.1")
assert l == [1, 1.1]
+ def test_iadd(self):
+ class A:
+ __metaclass__ = nclassobj
+ def __init__(self):
+ self.l = []
+ def __iadd__(self, other):
+ self.l.append(other)
+ return self
+ a1 = a = A()
+ a += 1
+ assert a is a1
+ a += 2
+ assert a is a1
+ assert a.l == [1, 2]
+
More information about the Pypy-commit
mailing list