summaryrefslogtreecommitdiffstats
path: root/Objects/fileobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-09 18:14:59 (GMT)
committerGuido van Rossum <guido@python.org>2001-08-09 18:14:59 (GMT)
commit29206bc8a3641b6d15cd5c30a3a74658d582362a (patch)
tree155a31932040b205fa4b2a71b4d30da6764238c0 /Objects/fileobject.c
parent55c12d4d5bd6adc8e60d074fbb5f1d666c87422c (diff)
downloadcpython-29206bc8a3641b6d15cd5c30a3a74658d582362a.zip
cpython-29206bc8a3641b6d15cd5c30a3a74658d582362a.tar.gz
cpython-29206bc8a3641b6d15cd5c30a3a74658d582362a.tar.bz2
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. :-)
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r--Objects/fileobject.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index e01c439..946d41c 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);