summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs/multibytecodec.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/cjkcodecs/multibytecodec.c')
-rw-r--r--Modules/cjkcodecs/multibytecodec.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index dae82b7..81b3500 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -1220,6 +1220,8 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
cres = NULL;
for (;;) {
+ int endoffile;
+
if (sizehint < 0)
cres = PyObject_CallMethod(self->stream,
(char *)method, NULL);
@@ -1245,6 +1247,8 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
goto errorexit;
}
+ endoffile = (PyString_GET_SIZE(cres) == 0);
+
if (self->pendingsize > 0) {
PyObject *ctr;
char *ctrdata;
@@ -1272,7 +1276,7 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
(MultibyteStatefulDecoderContext *)self, &buf))
goto errorexit;
- if (rsize == 0 || sizehint < 0) { /* end of file */
+ if (endoffile || sizehint < 0) {
if (buf.inbuf < buf.inbuf_end &&
multibytecodec_decerror(self->codec, &self->state,
&buf, self->errors, MBERR_TOOFEW))