[pypy-svn] pypy shorter-float-repr: Avoid name collision and nasty recursion

amauryfa commits-noreply at bitbucket.org
Fri Jan 21 19:53:31 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: shorter-float-repr
Changeset: r41182:1b64a0d58e58
Date: 2011-01-21 19:46 +0100
http://bitbucket.org/pypy/pypy/changeset/1b64a0d58e58/

Log:	Avoid name collision and nasty recursion

diff --git a/pypy/rpython/rstr.py b/pypy/rpython/rstr.py
--- a/pypy/rpython/rstr.py
+++ b/pypy/rpython/rstr.py
@@ -712,7 +712,7 @@
 
     def ll_float(ll_str):
         from pypy.rpython.annlowlevel import hlstr
-        from pypy.rlib.rarithmetic import string_to_float
+        from pypy.rlib.rarithmetic import rstring_to_float
         s = hlstr(ll_str)
         assert s is not None
 
@@ -732,7 +732,7 @@
             else:
                 break
         assert end >= 0
-        return string_to_float(s[beg:end+1])
+        return rstring_to_float(s[beg:end+1])
 
     def ll_splitlines(cls, LIST, ll_str, keep_newlines):
         from pypy.rpython.annlowlevel import hlstr

diff --git a/pypy/rlib/rmarshal.py b/pypy/rlib/rmarshal.py
--- a/pypy/rlib/rmarshal.py
+++ b/pypy/rlib/rmarshal.py
@@ -7,7 +7,7 @@
 from pypy.annotation.listdef import ListDef, TooLateForChange
 from pypy.tool.pairtype import pair, pairtype
 from pypy.rlib.rarithmetic import formatd, r_longlong, intmask, LONG_BIT
-from pypy.rlib.rarithmetic import string_to_float
+from pypy.rlib.rarithmetic import rstring_to_float
 from pypy.rlib.unroll import unrolling_iterable
 
 class CannotMarshal(Exception):
@@ -205,7 +205,7 @@
         raise ValueError("expected a float")
     length = ord(readchr(loader))
     s = readstr(loader, length)
-    return string_to_float(s)
+    return rstring_to_float(s)
 add_loader(annmodel.SomeFloat(), load_float)
 
 def dump_string_or_none(buf, x):

diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -517,7 +517,7 @@
     r_int64 = int
 
 
-def string_to_float(s):
+def rstring_to_float(s):
     if USE_SHORT_FLOAT_REPR:
         from pypy.rlib.rdtoa import strtod
         return strtod(s)

diff --git a/pypy/rlib/test/test_rarithmetic.py b/pypy/rlib/test/test_rarithmetic.py
--- a/pypy/rlib/test/test_rarithmetic.py
+++ b/pypy/rlib/test/test_rarithmetic.py
@@ -377,13 +377,13 @@
         assert res == 1e-100
 
     def test_string_to_float(self):
-        from pypy.rlib.rarithmetic import string_to_float
+        from pypy.rlib.rarithmetic import rstring_to_float
         def func(x):
             if x == 0:
                 s = '1e23'
             else:
                 s = '-1e23'
-            return string_to_float(s)
+            return rstring_to_float(s)
 
         assert self.interpret(func, [0]) == 1e23
         assert self.interpret(func, [1]) == -1e23

diff --git a/pypy/objspace/std/strutil.py b/pypy/objspace/std/strutil.py
--- a/pypy/objspace/std/strutil.py
+++ b/pypy/objspace/std/strutil.py
@@ -2,7 +2,7 @@
 Pure Python implementation of string utilities.
 """
 
-from pypy.rlib.rarithmetic import ovfcheck, string_to_float, INFINITY, NAN
+from pypy.rlib.rarithmetic import ovfcheck, rstring_to_float, INFINITY, NAN
 from pypy.rlib.rbigint import rbigint, parse_digit_string
 from pypy.interpreter.error import OperationError
 import math
@@ -179,6 +179,6 @@
         return NAN
 
     try:
-        return string_to_float(s)
+        return rstring_to_float(s)
     except ValueError:
         raise ParseStringError("invalid literal for float()")


More information about the Pypy-commit mailing list