Charles-François Natali added the comment: > 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. ---------- nosy: +neologix _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17976> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com