Commit 29206bc8 authored by Guido van Rossum's avatar Guido van Rossum

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. :-)
parent 55c12d4d
...@@ -847,6 +847,12 @@ get_line(PyFileObject *f, int n) ...@@ -847,6 +847,12 @@ get_line(PyFileObject *f, int n)
if (c == '\n') if (c == '\n')
break; break;
if (c == EOF) { if (c == EOF) {
if (ferror(fp)) {
PyErr_SetFromErrno(PyExc_IOError);
clearerr(fp);
Py_DECREF(v);
return NULL;
}
clearerr(fp); clearerr(fp);
if (PyErr_CheckSignals()) { if (PyErr_CheckSignals()) {
Py_DECREF(v); Py_DECREF(v);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment