[pypy-svn] r48617 - pypy/branch/more-unicode-improvements/pypy/module/_codecs

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Nov 12 23:00:03 CET 2007


Author: cfbolz
Date: Mon Nov 12 23:00:03 2007
New Revision: 48617

Modified:
   pypy/branch/more-unicode-improvements/pypy/module/_codecs/__init__.py
   pypy/branch/more-unicode-improvements/pypy/module/_codecs/app_codecs.py
   pypy/branch/more-unicode-improvements/pypy/module/_codecs/interp_codecs.py
Log:
yet another decoder moved to use the runicode version


Modified: pypy/branch/more-unicode-improvements/pypy/module/_codecs/__init__.py
==============================================================================
--- pypy/branch/more-unicode-improvements/pypy/module/_codecs/__init__.py	(original)
+++ pypy/branch/more-unicode-improvements/pypy/module/_codecs/__init__.py	Mon Nov 12 23:00:03 2007
@@ -20,7 +20,6 @@
          'unicode_internal_encode' :  'app_codecs.unicode_internal_encode',
          'utf_7_decode' :  'app_codecs.utf_7_decode',
          'utf_7_encode' :  'app_codecs.utf_7_encode',
-         'utf_16_ex_decode' : 'app_codecs.utf_16_ex_decode',
          '_register_existing_errors': 'app_codecs._register_existing_errors',
     }
     interpleveldefs = {
@@ -44,6 +43,7 @@
          'utf_16_encode'    : 'interp_codecs.utf_16_encode',
          'utf_16_le_decode' : 'interp_codecs.utf_16_le_decode',
          'utf_16_le_encode' : 'interp_codecs.utf_16_le_encode',
+         'utf_16_ex_decode' : 'interp_codecs.utf_16_ex_decode',
     }
 
     def setup_after_space_initialization(self):

Modified: pypy/branch/more-unicode-improvements/pypy/module/_codecs/app_codecs.py
==============================================================================
--- pypy/branch/more-unicode-improvements/pypy/module/_codecs/app_codecs.py	(original)
+++ pypy/branch/more-unicode-improvements/pypy/module/_codecs/app_codecs.py	Mon Nov 12 23:00:03 2007
@@ -150,22 +150,6 @@
         res = u''.join(p)
         return res, len(res)
 
-def utf_16_ex_decode( data, errors='strict', byteorder=0, final=0):
-    """None
-    """
-    if byteorder == 0:
-        bm = 'native'
-    elif byteorder == -1:
-        bm = 'little'
-    else:
-        bm = 'big'
-    consumed = len(data)
-    if final:
-        consumed = 0
-    res, consumed, byteorder = PyUnicode_DecodeUTF16Stateful(data, len(data), errors, bm, final)
-    res = ''.join(res)
-    return res, consumed, byteorder
-
 # XXX needs error messages when the input is invalid
 def escape_decode(data, errors='strict'):
     """None

Modified: pypy/branch/more-unicode-improvements/pypy/module/_codecs/interp_codecs.py
==============================================================================
--- pypy/branch/more-unicode-improvements/pypy/module/_codecs/interp_codecs.py	(original)
+++ pypy/branch/more-unicode-improvements/pypy/module/_codecs/interp_codecs.py	Mon Nov 12 23:00:03 2007
@@ -239,3 +239,25 @@
          "utf_16_le_decode",
          ]:
     make_decoder_wrapper(decoders)
+
+
+def utf_16_ex_decode(space, data, errors='strict', byteorder=0, w_final=False):
+    """None
+    """
+    final = space.is_true(w_final)
+    state = space.fromcache(CodecState)
+    if byteorder == 0:
+        byteorder = 'native'
+    elif byteorder == -1:
+        byteorder = 'little'
+    else:
+        byteorder = 'big'
+    consumed = len(data)
+    if final:
+        consumed = 0
+    res, consumed, byteorder = runicode.str_decode_utf_16_helper(
+        data, len(data), errors, final, state.error_handler, byteorder)
+    return space.newtuple([space.wrap(res), space.wrap(consumed),
+                           space.wrap(byteorder)])
+utf_16_ex_decode.unwrap_spec = [ObjSpace, str, str, int, W_Root]
+



More information about the Pypy-commit mailing list