From: Guido van Rossum Date: Thu, 9 Aug 2001 18:14:59 +0000 (+0000) Subject: Apply anonymous SF patch #441229. X-Git-Tag: v2.2a3~705 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29206bc8a3641b6d15cd5c30a3a74658d582362a;p=python Apply anonymous SF patch #441229. Previously, f.read() and f.readlines() checked for errors on their file object and possibly raised an IOError, but f.readline() didn't. This patch makes f.readline() behave like the others. Note that I've added a call to clearerr() since the other calls to ferror() include that too. I have no way to test this code. :-) --- diff --git a/Objects/fileobject.c b/Objects/fileobject.c index e01c4398d6..946d41c22a 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -847,6 +847,12 @@ get_line(PyFileObject *f, int n) if (c == '\n') break; if (c == EOF) { + if (ferror(fp)) { + PyErr_SetFromErrno(PyExc_IOError); + clearerr(fp); + Py_DECREF(v); + return NULL; + } clearerr(fp); if (PyErr_CheckSignals()) { Py_DECREF(v);