[pypy-svn] r5599 - pypy/trunk/src/pypy/objspace/std

mwh at codespeak.net mwh at codespeak.net
Wed Jul 21 13:07:57 CEST 2004


Author: mwh
Date: Wed Jul 21 13:07:57 2004
New Revision: 5599

Modified:
   pypy/trunk/src/pypy/objspace/std/inttype.py
Log:
fix for int("too big for an int") or int(too-big-for-an-int.0).
not sure this is 100% correct.


Modified: pypy/trunk/src/pypy/objspace/std/inttype.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/inttype.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/inttype.py	Wed Jul 21 13:07:57 2004
@@ -33,9 +33,16 @@
         except OverflowError, e:
             raise OperationError(space.w_OverflowError,
                          space.wrap(str(e)))
-    w_obj = space.allocate_instance(W_IntObject, w_inttype)
-    w_obj.__init__(space, value)
-    return w_obj
+    if isinstance(value, long):
+        # XXX is this right??
+        from pypy.objspace.std.longobject import W_LongObject
+        w_obj = space.allocate_instance(W_LongObject, space.w_long)
+        w_obj.__init__(space, value)
+        return w_obj
+    else:
+        w_obj = space.allocate_instance(W_IntObject, w_inttype)
+        w_obj.__init__(space, value)
+        return w_obj
 
 # ____________________________________________________________
 



More information about the Pypy-commit mailing list