[pypy-svn] r9034 - pypy/dist/pypy/objspace/std

ac at codespeak.net ac at codespeak.net
Wed Feb 9 15:31:46 CET 2005


Author: ac
Date: Wed Feb  9 15:31:46 2005
New Revision: 9034

Modified:
   pypy/dist/pypy/objspace/std/longobject.py
Log:
Take proper care of Overflow when converting long -> float.

Modified: pypy/dist/pypy/objspace/std/longobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/longobject.py	(original)
+++ pypy/dist/pypy/objspace/std/longobject.py	Wed Feb  9 15:31:46 2005
@@ -33,7 +33,11 @@
 
 # long-to-float delegation
 def delegate_Long2Float(w_longobj):
-    return W_FloatObject(w_longobj.space, float(w_longobj.longval))
+    try:
+        return W_FloatObject(w_longobj.space, float(w_longobj.longval))
+    except OverflowError:
+        raise OperationError(w_longobj.space.w_OverflowError,
+                             w_longobj.space.wrap("long int too large to convert to float"))
 
 
 # long__Long is supposed to do nothing, unless it has



More information about the Pypy-commit mailing list