summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-24 20:17:55 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-24 20:17:55 (GMT)
commit6bcbef7da0127272aa97cdd43ec529bfe92c3251 (patch)
tree6649bf8138bd5830b8ac02cb9a9fdac41779b955 /Modules
parentf8473933083cd045bdb0bf0dda8516e268846bd5 (diff)
downloadcpython-6bcbef7da0127272aa97cdd43ec529bfe92c3251.zip
cpython-6bcbef7da0127272aa97cdd43ec529bfe92c3251.tar.gz
cpython-6bcbef7da0127272aa97cdd43ec529bfe92c3251.tar.bz2
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')
-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 af7ea5b..7b04f020 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;
@@ -514,7 +514,7 @@ multibytecodec_encode(MultibyteCodec *codec,
break;
}
- if (codec->encreset != NULL)
+ if (codec->encreset != NULL && (flags & MBENC_RESET))
for (;;) {
Py_ssize_t outleft;
@@ -784,8 +784,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)