diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-30 22:56:00 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-05-30 22:56:00 +0200 |
commit | d1cb68c7995fec87f0ffa90cf87922b387a5e7ef (patch) | |
tree | f92c074beace42f5d33813baeecb87692d33b379 /Modules/cjkcodecs/multibytecodec.c | |
parent | 7968b94eaffb3a0fc46b21a6044c9cad934906d4 (diff) | |
download | cpython-d1cb68c7995fec87f0ffa90cf87922b387a5e7ef.tar.gz |
Close #12171: IncrementalEncoder.reset() of CJK codecs (multibytecodec) calls
encreset() instead of decreset().
Diffstat (limited to 'Modules/cjkcodecs/multibytecodec.c')
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index bb8176f702..1b37845285 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; } |