[pypy-svn] r79632 - pypy/trunk/pypy/objspace/std

arigo at codespeak.net arigo at codespeak.net
Mon Nov 29 13:12:18 CET 2010


Author: arigo
Date: Mon Nov 29 13:12:17 2010
New Revision: 79632

Modified:
   pypy/trunk/pypy/objspace/std/objspace.py
Log:
Support space.wrap(x), where x is a special shorter-than-usual
integer type.


Modified: pypy/trunk/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/pypy/objspace/std/objspace.py	Mon Nov 29 13:12:17 2010
@@ -9,7 +9,7 @@
 from pypy.objspace.descroperation import DescrOperation, raiseattrerror
 from pypy.rlib.objectmodel import instantiate, r_dict, specialize
 from pypy.rlib.debug import make_sure_not_resized
-from pypy.rlib.rarithmetic import base_int
+from pypy.rlib.rarithmetic import base_int, widen
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.jit import hint
 from pypy.tool.sourcetools import func_with_new_name
@@ -176,7 +176,11 @@
             #print 'wrapping', x, '->', w_result
             return w_result
         if isinstance(x, base_int):
-            return W_LongObject.fromrarith_int(x)
+            x = widen(x)
+            if isinstance(x, int):
+                return self.newint(x)
+            else:
+                return W_LongObject.fromrarith_int(x)
 
         # _____ below here is where the annotator should not get _____
 



More information about the Pypy-commit mailing list