summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-05-30 20:56:00 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-05-30 20:56:00 (GMT)
commite15dce3d18d333b91a567fb8d611ca74781e4f13 (patch)
tree332611b0ce447ea367d486b60a122aa897bec6c7 /Modules/cjkcodecs
parentebbb3b797297506b91c2b9256bcd0fe92e8b47b8 (diff)
downloadcpython-e15dce3d18d333b91a567fb8d611ca74781e4f13.zip
cpython-e15dce3d18d333b91a567fb8d611ca74781e4f13.tar.gz
cpython-e15dce3d18d333b91a567fb8d611ca74781e4f13.tar.bz2
Close #12171: IncrementalEncoder.reset() of CJK codecs (multibytecodec) calls
encreset() instead of decreset().
Diffstat (limited to 'Modules/cjkcodecs')
-rw-r--r--Modules/cjkcodecs/multibytecodec.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index bb8176f..1b37845 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -901,11 +901,17 @@ mbiencoder_encode(MultibyteIncrementalEncoderObject *self,
static PyObject *
mbiencoder_reset(MultibyteIncrementalEncoderObject *self)
{
- if (self->codec->decreset != NULL &&
- self->codec->decreset(&self->state, self->codec->config) != 0)
- return NULL;
+ /* Longest output: 4 bytes (b'\x0F\x1F(B') with ISO 2022 */
+ unsigned char buffer[4], *outbuf;
+ Py_ssize_t r;
+ if (self->codec->encreset != NULL) {
+ outbuf = buffer;
+ r = self->codec->encreset(&self->state, self->codec->config,
+ &outbuf, sizeof(buffer));
+ if (r != 0)
+ return NULL;
+ }
self->pendingsize = 0;
-
Py_RETURN_NONE;
}