[pypy-svn] r10833 - in pypy/dist/pypy/objspace: . test

arigo at codespeak.net arigo at codespeak.net
Mon Apr 18 22:10:37 CEST 2005


Author: arigo
Date: Mon Apr 18 22:10:37 2005
New Revision: 10833

Modified:
   pypy/dist/pypy/objspace/descroperation.py
   pypy/dist/pypy/objspace/test/test_descroperation.py
Log:
Bug detected by the annotator: our **= operator never worked.
inplace_pow() to be special-cased in descroperation.


Modified: pypy/dist/pypy/objspace/descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/descroperation.py	(original)
+++ pypy/dist/pypy/objspace/descroperation.py	Mon Apr 18 22:10:37 2005
@@ -253,6 +253,14 @@
         raise OperationError(space.w_TypeError,
                 space.wrap("operands do not support **"))
 
+    def inplace_pow(space, w_lhs, w_rhs):
+        w_impl = space.lookup(w_lhs, '__ipow__')
+        if w_impl is not None:
+            w_res = space.get_and_call_function(w_impl, w_lhs, w_rhs)
+            if _check_notimplemented(space, w_res):
+                return w_res
+        return space.pow(w_lhs, w_rhs, space.w_None)
+
     def contains(space, w_container, w_item):
         w_descr = space.lookup(w_container, '__contains__')
         if w_descr is not None:

Modified: pypy/dist/pypy/objspace/test/test_descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/test/test_descroperation.py	(original)
+++ pypy/dist/pypy/objspace/test/test_descroperation.py	Mon Apr 18 22:10:37 2005
@@ -13,3 +13,8 @@
         sq = Sq()
 
         assert sq[1:3] == (1,3)
+
+    def test_ipow(self):
+        x = 2
+        x **= 5
+        assert x == 32



More information about the Pypy-commit mailing list