]> granicus.if.org Git - python/commitdiff
Issue #3575: Incremental decoder's decode function now takes bytearray
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sun, 17 Aug 2008 12:59:57 +0000 (12:59 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sun, 17 Aug 2008 12:59:57 +0000 (12:59 +0000)
by using 's*' instead of 't#'

Misc/NEWS
Modules/cjkcodecs/multibytecodec.c

index 0cbebc51ef2c20723f85503a9f7e475c1472a12f..0e2adb0c6852244bd03e812e108af56774d8454b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #3575: Incremental decoder's decode function now takes bytearray
+  by using 's*' instead of 't#'.
+
 - Issue #2222: Fixed reference leak when occured os.rename()
   fails unicode conversion on 2nd parameter. (windows only)
 
index 95b2278e6c608edfcfd80b0f15ce26be697598eb..67c25b164667e89a1c17a7513eec02c9fc168263 100644 (file)
@@ -1034,12 +1034,15 @@ mbidecoder_decode(MultibyteIncrementalDecoderObject *self,
 {
        MultibyteDecodeBuffer buf;
        char *data, *wdata = NULL;
+       Py_buffer pdata;
        Py_ssize_t wsize, finalsize = 0, size, origpending;
        int final = 0;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "t#|i:decode",
-                       incrementalkwarglist, &data, &size, &final))
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s*|i:decode",
+                       incrementalkwarglist, &pdata, &final))
                return NULL;
+       data = pdata.buf;
+       size = pdata.len;
 
        buf.outobj = buf.excobj = NULL;
        origpending = self->pendingsize;
@@ -1088,12 +1091,14 @@ mbidecoder_decode(MultibyteIncrementalDecoderObject *self,
                if (PyUnicode_Resize(&buf.outobj, finalsize) == -1)
                        goto errorexit;
 
+       PyBuffer_Release(&pdata);
        if (wdata != data)
                PyMem_Del(wdata);
        Py_XDECREF(buf.excobj);
        return buf.outobj;
 
 errorexit:
+       PyBuffer_Release(&pdata);
        if (wdata != NULL && wdata != data)
                PyMem_Del(wdata);
        Py_XDECREF(buf.excobj);