[pypy-svn] pypy default: Throw DeprecationWarnings when using complex divmod(), // or %.

arigo commits-noreply at bitbucket.org
Mon Jan 31 11:25:09 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r41492:c6328e0f7a9b
Date: 2011-01-30 18:22 +0100
http://bitbucket.org/pypy/pypy/changeset/c6328e0f7a9b/

Log:	Throw DeprecationWarnings when using complex divmod(), // or %.

diff --git a/pypy/objspace/std/complexobject.py b/pypy/objspace/std/complexobject.py
--- a/pypy/objspace/std/complexobject.py
+++ b/pypy/objspace/std/complexobject.py
@@ -62,7 +62,11 @@
             ir = (i1 * ratio - r1) / denom
         return W_ComplexObject(rr,ir)
 
-    def divmod(self, other):
+    def divmod(self, space, other):
+        space.warn(
+            "complex divmod(), // and % are deprecated",
+            space.w_DeprecationWarning
+        )
         w_div = self.div(other)
         div = math.floor(w_div.realval)
         w_mod = self.sub(
@@ -157,13 +161,13 @@
 
 def mod__Complex_Complex(space, w_complex1, w_complex2):
     try:
-        return w_complex1.divmod(w_complex2)[1]
+        return w_complex1.divmod(space, w_complex2)[1]
     except ZeroDivisionError, e:
         raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
 
 def divmod__Complex_Complex(space, w_complex1, w_complex2):
     try:
-        div, mod = w_complex1.divmod(w_complex2)
+        div, mod = w_complex1.divmod(space, w_complex2)
     except ZeroDivisionError, e:
         raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
     return space.newtuple([div, mod])
@@ -171,7 +175,7 @@
 def floordiv__Complex_Complex(space, w_complex1, w_complex2):
     # don't care about the slight slowdown you get from using divmod
     try:
-        return w_complex1.divmod(w_complex2)[0]
+        return w_complex1.divmod(space, w_complex2)[0]
     except ZeroDivisionError, e:
         raise OperationError(space.w_ZeroDivisionError, space.wrap(str(e)))
 


More information about the Pypy-commit mailing list