summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-24 20:29:13 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-24 20:29:13 (GMT)
commit40b41e1ffd4efc5718ed438a725765d6e4d1feae (patch)
tree9874cedb9f5d625f5bc05915f379ef41ced831a0 /Modules/cjkcodecs
parent80a09c70bfa4592a8067274f49f24f9fffe8b795 (diff)
downloadcpython-40b41e1ffd4efc5718ed438a725765d6e4d1feae.zip
cpython-40b41e1ffd4efc5718ed438a725765d6e4d1feae.tar.gz
cpython-40b41e1ffd4efc5718ed438a725765d6e4d1feae.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/cjkcodecs')
-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 1f31595..14fed3e 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -471,7 +471,7 @@ multibytecodec_encode(MultibyteCodec *codec,
MultibyteEncodeBuffer buf;
Py_ssize_t finalsize, r = 0;
- if (datalen == 0)
+ if (datalen == 0 && !(flags & MBENC_RESET))
return PyString_FromString("");
buf.excobj = NULL;
@@ -506,7 +506,7 @@ multibytecodec_encode(MultibyteCodec *codec,
break;
}
- if (codec->encreset != NULL)
+ if (codec->encreset != NULL && (flags & MBENC_RESET))
for (;;) {
Py_ssize_t outleft;
@@ -776,8 +776,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)