Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3k
Changeset: r58338:82d0647b840c
Date: 2012-10-21 09:12 +0200
http://bitbucket.org/pypy/pypy/changeset/82d0647b840c/

Log:    Fix own tests in module/_codecs

diff --git a/pypy/module/_codecs/interp_codecs.py 
b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -454,7 +454,7 @@
     make_decoder_wrapper('mbcs_decode')
 
 # utf-8 functions are not regular, because we have to pass
-# "allow_surrogates=True"
+# "allow_surrogates=False"
 @unwrap_spec(uni=unicode, errors='str_or_None')
 def utf_8_encode(space, uni, errors="strict"):
     if errors is None:
@@ -462,7 +462,7 @@
     state = space.fromcache(CodecState)
     result = runicode.unicode_encode_utf_8(
         uni, len(uni), errors, state.encode_error_handler,
-        allow_surrogates=True)
+        allow_surrogates=False)
     return space.newtuple([space.wrapbytes(result), space.wrap(len(uni))])
 
 @unwrap_spec(string='bufferstr', errors='str_or_None',
@@ -475,7 +475,7 @@
     result, consumed = runicode.str_decode_utf_8(
         string, len(string), errors,
         final, state.decode_error_handler,
-        allow_surrogates=True)
+        allow_surrogates=False)
     return space.newtuple([space.wrap(result), space.wrap(consumed)])
 
 @unwrap_spec(data="bufferstr", errors='str_or_None', byteorder=int,
diff --git a/pypy/rlib/runicode.py b/pypy/rlib/runicode.py
--- a/pypy/rlib/runicode.py
+++ b/pypy/rlib/runicode.py
@@ -295,13 +295,7 @@
                         r, pos = errorhandler(errors, 'utf-8',
                                               'surrogates not allowed',
                                               s, pos-1, pos)
-                        for ch in r:
-                            if ord(ch) < 0x80:
-                                result.append(chr(ord(ch)))
-                            else:
-                                errorhandler('strict', 'utf-8',
-                                             'surrogates not allowed',
-                                             s, pos-1, pos)
+                        result.append(r)
                         continue
                     # else: Fall through and handles isolated high surrogates
                 result.append((chr((0xe0 | (ch >> 12)))))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to