[issue1706039] Added clearerr() to clear EOF state

Scott Dial report at bugs.python.org
Tue Dec 23 18:13:23 CET 2008


Scott Dial <scott at scottdial.com> added the comment:

They differ because in Py_UniversalNewlineFgets() there is a call to
FLOCKFILE(), and it seemed appropriate to ensure that clearerr() was
called after locking the FILE stream. I certainly pondered over whether
it made a difference to do it before or after, and it would seem to me
that if we are bothering to lock the FILE stream then we would care to
ensure that the first GETC() after locking reaps the benefit of having
called clearerr(). In the cases that we fall into fread and fgets, we
may actually need to be doing:

    FLOCKFILE(stream)
    clearerr(stream);
    result = fgets(buf, n, stream);
    FUNLOCKFILE(stream);
    return result;

One nitpick is that the testcase was appended to the StdoutTests class
instead of OtherFileTests class, which would seem more appropriate.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1706039>
_______________________________________


More information about the Python-bugs-list mailing list