Index: Objects/fileobject.c =================================================================== --- Objects/fileobject.c (revision 67739) +++ Objects/fileobject.c (working copy) @@ -2336,12 +2336,21 @@ return NULL; } univ_newline = ((PyFileObject *)fobj)->f_univ_newline; - if ( !univ_newline ) + if ( !univ_newline ) { + /* Issue #1706039: Support continued reading from a file even after + * EOF was hit. + */ + clearerr(stream); return fgets(buf, n, stream); + } newlinetypes = ((PyFileObject *)fobj)->f_newlinetypes; skipnextlf = ((PyFileObject *)fobj)->f_skipnextlf; } FLOCKFILE(stream); + /* Issue #1706039: Support continued reading from a file even after + * EOF was hit. + */ + clearerr(stream); c = 'x'; /* Shut up gcc warning */ while (--n > 0 && (c = GETC(stream)) != EOF ) { if (skipnextlf ) { @@ -2424,6 +2433,10 @@ errno = ENXIO; /* What can you do... */ return 0; } + /* Issue #1706039: Support continued reading from a file even after + * EOF was hit. + */ + clearerr(stream); if (!f->f_univ_newline) return fread(buf, 1, n, stream); newlinetypes = f->f_newlinetypes;