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 jasujm
Recipients jasujm, neologix, pitrou, serhiy.storchaka
Date 2013-05-14.19:04:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1368558278.4.0.26845791202.issue17976@psf.upfronthosting.co.za>
In-reply-to
Content
Thank you for your comments.

> 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).

Strange. I too modified Serchiy's code and my version of glibc (2.15) set the error flag at the same fwrite call as errno was set:

setvbuf 0 0 0
fwrite 5 0 0
fwrite 1 28 1
fwrite 1 28 1

(the last column being the return value of ferror after each fwrite call)

I've trusted ferror until now but I'm not an expert on the subject. It's a good point that errno is set by the underlying system call and is thus more reliable. So would checking errno be sufficient (in addition to checking that the lengths agree)? It can only serve to make file_write more robust.
History
Date User Action Args
2013-05-14 19:04:38jasujmsetrecipients: + jasujm, pitrou, neologix, serhiy.storchaka
2013-05-14 19:04:38jasujmsetmessageid: <1368558278.4.0.26845791202.issue17976@psf.upfronthosting.co.za>
2013-05-14 19:04:38jasujmlinkissue17976 messages
2013-05-14 19:04:38jasujmcreate