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
Date 2013-05-14.16:26:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1368548767.55.0.919021731763.issue17976@psf.upfronthosting.co.za>
In-reply-to
Content
> I assume my glibc and fwrite aren't broken though

Actually, it's a glibc bug when the last character is a '\n':

$ python -c "f = open('/dev/full', 'w', 1); f.write('hello'); f.close()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
IOError: [Errno 28] No space left on device

Normal.

Now, you add a trailing newline:
$ strace -e write python -c "f = open('/dev/full', 'w', 1); f.write('hello'); f.write('\n'); f.close()"
write(3, "hello\n", 6)                  = -1 ENOSPC (No space left on device)

write() still returns ENOSPC, but it gets ignored by fwrite().

I've had a quick look at the source, and I think the culprit is here:
http://sourceware.org/git/?p=glibc.git;a=blob;f=libio/fileops.c#l1270

1336       if (do_write)
1337         {
1338           count = new_do_write (f, s, do_write);
1339           to_do -= count;
1340           if (count < do_write)
1341             return n - to_do;
1342         }

It looks like there's a check missing here for count < 0.
History
Date User Action Args
2013-05-14 16:26:07neologixsetrecipients: + neologix, jasujm
2013-05-14 16:26:07neologixsetmessageid: <1368548767.55.0.919021731763.issue17976@psf.upfronthosting.co.za>
2013-05-14 16:26:07neologixlinkissue17976 messages
2013-05-14 16:26:07neologixcreate