Author: Armin Rigo <ar...@tunes.org>
Branch: 
Changeset: r46144:801f2ddd52be
Date: 2011-07-31 18:19 +0200
http://bitbucket.org/pypy/pypy/changeset/801f2ddd52be/

Log:    Minor simplification of the interface.

diff --git a/pypy/module/_multibytecodec/c_codecs.py 
b/pypy/module/_multibytecodec/c_codecs.py
--- a/pypy/module/_multibytecodec/c_codecs.py
+++ b/pypy/module/_multibytecodec/c_codecs.py
@@ -126,7 +126,7 @@
         pypy_cjk_dec_free(decodebuf)
 
 def decodeex(decodebuf, stringdata, errors="strict", errorcb=None, namecb=None,
-             incompletepos=None):
+             ignore_error=0):
     inleft = len(stringdata)
     inbuf = rffi.get_nonmovingbuffer(stringdata)
     try:
@@ -134,10 +134,7 @@
             raise MemoryError
         while True:
             r = pypy_cjk_dec_chunk(decodebuf)
-            if r == 0:
-                break
-            if incompletepos is not None and r == MBERR_TOOFEW:
-                incompletepos[0] = pypy_cjk_dec_inbuf_consumed(decodebuf)
+            if r == 0 or r == ignore_error:
                 break
             multibytecodec_decerror(decodebuf, r, errors,
                                     errorcb, namecb, stringdata)
diff --git a/pypy/module/_multibytecodec/test/test_c_codecs.py 
b/pypy/module/_multibytecodec/test/test_c_codecs.py
--- a/pypy/module/_multibytecodec/test/test_c_codecs.py
+++ b/pypy/module/_multibytecodec/test/test_c_codecs.py
@@ -62,10 +62,11 @@
            u'\u73b7',   # h
            ]):
         buf += c
-        incompletepos = [len(buf)]
-        u = c_codecs.decodeex(decodebuf, buf, incompletepos=incompletepos)
+        u = c_codecs.decodeex(decodebuf, buf,
+                              ignore_error = c_codecs.MBERR_TOOFEW)
         assert u == output
-        buf = buf[incompletepos[0]:]
+        incompletepos = c_codecs.pypy_cjk_dec_inbuf_consumed(decodebuf)
+        buf = buf[incompletepos:]
     assert buf == ''
     c_codecs.pypy_cjk_dec_free(decodebuf)
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to