[pypy-commit] pypy float-bytes-2: Make it work with exceptions.

alex_gaynor noreply at buildbot.pypy.org
Tue Mar 27 23:23:56 CEST 2012


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: float-bytes-2
Changeset: r54034:1d2ad3c4d5c9
Date: 2012-03-27 17:23 -0400
http://bitbucket.org/pypy/pypy/changeset/1d2ad3c4d5c9/

Log:	Make it work with exceptions.

diff --git a/pypy/rlib/longlong2float.py b/pypy/rlib/longlong2float.py
--- a/pypy/rlib/longlong2float.py
+++ b/pypy/rlib/longlong2float.py
@@ -87,6 +87,7 @@
 
     def specialize_call(self, hop):
         [v_float] = hop.inputargs(lltype.Float)
+        hop.exception_cannot_occur()
         return hop.genop("convert_float_bytes_to_longlong", [v_float], resulttype=lltype.SignedLongLong)
 
 class LongLong2FloatEntry(ExtRegistryEntry):
@@ -98,4 +99,5 @@
 
     def specialize_call(self, hop):
         [v_longlong] = hop.inputargs(lltype.SignedLongLong)
+        hop.exception_cannot_occur()
         return hop.genop("convert_longlong_bytes_to_float", [v_longlong], resulttype=lltype.Float)
diff --git a/pypy/rlib/test/test_longlong2float.py b/pypy/rlib/test/test_longlong2float.py
--- a/pypy/rlib/test/test_longlong2float.py
+++ b/pypy/rlib/test/test_longlong2float.py
@@ -33,8 +33,15 @@
         assert repr(res) == repr(x)
 
 def test_interpreted():
+    def f(f1):
+        try:
+            ll = float2longlong(f1)
+            return longlong2float(ll)
+        except Exception:
+            return 500
+
     for x in enum_floats():
-        res = interpret(fn, [x])
+        res = interpret(f, [x])
         assert repr(res) == repr(x)
 
 # ____________________________________________________________


More information about the pypy-commit mailing list