This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients jasujm, neologix, pitrou, serhiy.storchaka
Date 2013-05-14.17:59:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAH_1eM1JkNw4Nujd9ZHriZi9fvZxgji1y-PbX1De0nj7gvW_Hg@mail.gmail.com>
In-reply-to <1368551480.63.0.597355934988.issue17976@psf.upfronthosting.co.za>
Content
> Why is ferror() not reliable?

Because the glibc doesn't check the errno return code after the
write() syscall, and thus doesn't set the file's stream error flag
(ferror() just checks this flag).

That's what I saw from the code.

I was a little surprised when Jaako says that ferror() is enough to
detect this, so I modified Serhiy code to print ferror(), and actually
ferror() reports an error for subsequent writes, not for the first one
(probably because the error goes unnoticed only when the buffer is in
a particular state).

So in short, errno is the only reliable way to check for errors :-(
History
Date User Action Args
2013-05-14 17:59:56neologixsetrecipients: + neologix, pitrou, serhiy.storchaka, jasujm
2013-05-14 17:59:56neologixlinkissue17976 messages
2013-05-14 17:59:55neologixcreate