[pypy-svn] r79724 - in pypy/branch/fast-forward/pypy: module/__builtin__ objspace/std

afa at codespeak.net afa at codespeak.net
Wed Dec 1 20:08:49 CET 2010


Author: afa
Date: Wed Dec  1 20:08:45 2010
New Revision: 79724

Modified:
   pypy/branch/fast-forward/pypy/module/__builtin__/app_operation.py
   pypy/branch/fast-forward/pypy/objspace/std/complexobject.py
   pypy/branch/fast-forward/pypy/objspace/std/floatobject.py
Log:
Some fixes to translate with cpython2.5 (or pypy-1.4!)

- use the rarithmetic.copysign(), which has a fall-back implementation
- don't use the global builtin "format()", it confuses geninterp.


Modified: pypy/branch/fast-forward/pypy/module/__builtin__/app_operation.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/__builtin__/app_operation.py	(original)
+++ pypy/branch/fast-forward/pypy/module/__builtin__/app_operation.py	Wed Dec  1 20:08:45 2010
@@ -1,4 +1,4 @@
 def bin(x):
     if not isinstance(x, (int, long)):
         raise TypeError("must be int or long")
-    return format(x, "#b")
+    return x.__format__("#b")

Modified: pypy/branch/fast-forward/pypy/objspace/std/complexobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/complexobject.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/complexobject.py	Wed Dec  1 20:08:45 2010
@@ -3,7 +3,7 @@
 from pypy.objspace.std.model import registerimplementation, W_Object
 from pypy.objspace.std.register_all import register_all
 from pypy.objspace.std.floatobject import W_FloatObject, _hash_float
-from pypy.rlib.rarithmetic import formatd, isinf, isnan
+from pypy.rlib.rarithmetic import formatd, isinf, isnan, copysign
 
 import math
 
@@ -273,16 +273,16 @@
     return format_float(x, "%.12g")
 
 def repr__Complex(space, w_complex):
-    if w_complex.realval == 0 and math.copysign(1., w_complex.realval) == 1.:
+    if w_complex.realval == 0 and copysign(1., w_complex.realval) == 1.:
         return space.wrap(repr_format(w_complex.imagval) + 'j')
-    sign = (math.copysign(1., w_complex.imagval) == 1.) and '+' or ''
+    sign = (copysign(1., w_complex.imagval) == 1.) and '+' or ''
     return space.wrap('(' + repr_format(w_complex.realval)
                       + sign + repr_format(w_complex.imagval) + 'j)')
 
 def str__Complex(space, w_complex):
-    if w_complex.realval == 0 and math.copysign(1., w_complex.realval) == 1.:
+    if w_complex.realval == 0 and copysign(1., w_complex.realval) == 1.:
         return space.wrap(str_format(w_complex.imagval) + 'j')
-    sign = (math.copysign(1., w_complex.imagval) == 1.) and '+' or ''
+    sign = (copysign(1., w_complex.imagval) == 1.) and '+' or ''
     return space.wrap('(' + str_format(w_complex.realval)
                       + sign + str_format(w_complex.imagval) + 'j)')
 

Modified: pypy/branch/fast-forward/pypy/objspace/std/floatobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/objspace/std/floatobject.py	(original)
+++ pypy/branch/fast-forward/pypy/objspace/std/floatobject.py	Wed Dec  1 20:08:45 2010
@@ -9,7 +9,7 @@
 from pypy.objspace.std.noneobject import W_NoneObject
 from pypy.objspace.std.longobject import W_LongObject
 from pypy.rlib.rarithmetic import ovfcheck_float_to_int, intmask, isinf, isnan
-from pypy.rlib.rarithmetic import formatd, LONG_BIT, INFINITY
+from pypy.rlib.rarithmetic import formatd, LONG_BIT, INFINITY, copysign
 from pypy.rlib.rbigint import rbigint
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib import rfloat
@@ -102,7 +102,7 @@
     if isinf(value) or isnan(value):
         return str__Float(space, w_float)
     if value == 0.0:
-        if math.copysign(1., value) == -1.:
+        if copysign(1., value) == -1.:
             return space.wrap("-0x0.0p+0")
         else:
             return space.wrap("0x0.0p+0")



More information about the Pypy-commit mailing list