summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs/multibytecodec.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-24 20:24:11 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-24 20:24:11 (GMT)
commiteb734f77adb23a3cfe90a21679b74aee404d1a31 (patch)
treef010fb4195a42056ae3ae0f7b88410cec08115c8 /Modules/cjkcodecs/multibytecodec.c
parent19fb53c1195653e87b9197211015c624960c7b95 (diff)
parentd48ba0bde5bd535e9aa4c90cb122c0197f862e68 (diff)
downloadcpython-eb734f77adb23a3cfe90a21679b74aee404d1a31.zip
cpython-eb734f77adb23a3cfe90a21679b74aee404d1a31.tar.gz
cpython-eb734f77adb23a3cfe90a21679b74aee404d1a31.tar.bz2
(Merge 3.2) Issue #12100: Don't reset incremental encoders of CJK codecs at
each call to their encode() method anymore, but continue to call the reset() method if the final argument is True.
Diffstat (limited to 'Modules/cjkcodecs/multibytecodec.c')
-rw-r--r--Modules/cjkcodecs/multibytecodec.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index e137ff6..bb8176f 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -479,7 +479,7 @@ multibytecodec_encode(MultibyteCodec *codec,
MultibyteEncodeBuffer buf;
Py_ssize_t finalsize, r = 0;
- if (datalen == 0)
+ if (datalen == 0 && !(flags & MBENC_RESET))
return PyBytes_FromStringAndSize(NULL, 0);
buf.excobj = NULL;
@@ -515,7 +515,7 @@ multibytecodec_encode(MultibyteCodec *codec,
break;
}
- if (codec->encreset != NULL)
+ if (codec->encreset != NULL && (flags & MBENC_RESET))
for (;;) {
Py_ssize_t outleft;
@@ -785,8 +785,8 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx,
inbuf_end = inbuf + datalen;
r = multibytecodec_encode(ctx->codec, &ctx->state,
- (const Py_UNICODE **)&inbuf,
- datalen, ctx->errors, final ? MBENC_FLUSH : 0);
+ (const Py_UNICODE **)&inbuf, datalen,
+ ctx->errors, final ? MBENC_FLUSH | MBENC_RESET : 0);
if (r == NULL) {
/* recover the original pending buffer */
if (origpending > 0)