[pypy-svn] r77427 - pypy/branch/fast-forward/pypy/rlib

afa at codespeak.net afa at codespeak.net
Tue Sep 28 09:46:54 CEST 2010


Author: afa
Date: Tue Sep 28 09:46:52 2010
New Revision: 77427

Modified:
   pypy/branch/fast-forward/pypy/rlib/runicode.py
Log:
Fix translation: large unsigned ints are not RPython.


Modified: pypy/branch/fast-forward/pypy/rlib/runicode.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rlib/runicode.py	(original)
+++ pypy/branch/fast-forward/pypy/rlib/runicode.py	Tue Sep 28 09:46:52 2010
@@ -3,7 +3,7 @@
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.rlib.objectmodel import we_are_translated, specialize
 from pypy.rlib.rstring import StringBuilder, UnicodeBuilder
-from pypy.rlib.rarithmetic import r_uint
+from pypy.rlib.rarithmetic import r_uint, intmask
 
 if rffi.sizeof(lltype.UniChar) == 4:
     MAXUNICODE = 0x10ffff
@@ -438,6 +438,9 @@
                                                          errorhandler, "little")
     return result, length
 
+BOM32_DIRECT  = intmask(0x0000FEFF)
+BOM32_REVERSE = intmask(0xFFFE0000)
+
 def str_decode_utf_32_helper(s, size, errors, final=True,
                              errorhandler=None,
                              byteorder="native"):
@@ -460,18 +463,18 @@
             bom = ((ord(s[iorder[3]]) << 24) | (ord(s[iorder[2]]) << 16) |
                    (ord(s[iorder[1]]) << 8)  | ord(s[iorder[0]]))
             if BYTEORDER == 'little':
-                if bom == 0x0000FEFF:
+                if bom == BOM32_DIRECT:
                     pos += 4
                     bo = -1
-                elif bom == 0xFFFE0000:
+                elif bom == BOM32_REVERSE:
                     pos += 4
                     bo = 1
             else:
-                if bom == 0x0000FEFF:
-                    pos += 2
+                if bom == BOM32_DIRECT:
+                    pos += 4
                     bo = 1
-                elif bom == 0xFFFE0000:
-                    pos += 2
+                elif bom == BOM32_REVERSE:
+                    pos += 4
                     bo = -1
     elif byteorder == 'little':
         bo = -1



More information about the Pypy-commit mailing list