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. :-)
This commit is contained in:
Guido van Rossum 2001-08-09 18:14:59 +00:00
parent 55c12d4d5b
commit 29206bc8a3
1 changed files with 6 additions and 0 deletions

View File

@ -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);