[pypy-svn] pypy ootype-virtualrefs: don't use ll_ specialization for the lltype part of this function; also, write a failing test for the C backend

antocuni commits-noreply at bitbucket.org
Fri Apr 8 10:25:28 CEST 2011


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: ootype-virtualrefs
Changeset: r43208:ada41af85c55
Date: 2011-04-08 10:18 +0200
http://bitbucket.org/pypy/pypy/changeset/ada41af85c55/

Log:	don't use ll_ specialization for the lltype part of this function;
	also, write a failing test for the C backend

diff --git a/pypy/translator/c/test/test_lltyped.py b/pypy/translator/c/test/test_lltyped.py
--- a/pypy/translator/c/test/test_lltyped.py
+++ b/pypy/translator/c/test/test_lltyped.py
@@ -895,3 +895,10 @@
         fn = self.getcompiled(llf)
         assert fn() == 45
 
+    def test_rstring_to_float(self):
+        from pypy.rlib.rfloat import rstring_to_float
+        def llf(i):
+            s = ['42.3', '123.4'][i]
+            return rstring_to_float(s)
+        fn = self.getcompiled(llf, [int])
+        assert fn(0) == 42.3

diff --git a/pypy/rlib/rfloat.py b/pypy/rlib/rfloat.py
--- a/pypy/rlib/rfloat.py
+++ b/pypy/rlib/rfloat.py
@@ -43,13 +43,8 @@
     lls = oostr(s)
     return ootype.ooparse_float(lls)
 
-def ll_rstring_to_float(lls):
-    from pypy.rpython.annlowlevel import hlstr
-    s = hlstr(lls)
-    return rstring_to_float_impl(s)
-
-register_external(rstring_to_float, [SomeString(can_be_None=True)], float,
-                  llimpl=ll_rstring_to_float,
+register_external(rstring_to_float, [SomeString(can_be_None=False)], float,
+                  llimpl=rstring_to_float_impl,
                   ooimpl=oo_rstring_to_float)
 
 


More information about the Pypy-commit mailing list