[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Agree. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset 24a043355050 by Serhiy Storchaka in branch '2.7': Circumventing a bug in glibc (issue #17976). http://hg.python.org/cpython/rev/24a043355050 -- ___ Python tracker

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread Jaakko Moisio
Jaakko Moisio added the comment: The new patch is fine as it is, but my logic behind using err_flag was the following: err_flag was set solely based on the inspection of return value of fwrite and ferror, without referencing to errno. It is of course true that at the same time errno is set to

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread STINNER Victor
STINNER Victor added the comment: > The complete fix is maybe to write fflush() before fclose(), or at least > raise an exception if fclose() returns a non-zero result. Correctly, > file.close() returns a number in case of an error... Oh sorry, I missed the line "if (sts == -1) ..." which rais

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Are you have Python code which exposes a bug? -- ___ Python tracker ___ ___ Python-bugs-list maili

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread STINNER Victor
STINNER Victor added the comment: I played with fullwrite.c and now think that the fix is incomplete. fwrite() may succeed to write data into the buffer, but you may get the error on fflush() or fclose(). Try attached fullwrite2.c: fwrite() succeed (written=len, errno=result=0), whereas fclos

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread STINNER Victor
STINNER Victor added the comment: (I was trying to report the issue upstream.) -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset 237deaf9ba64 by Serhiy Storchaka in branch '2.7': Skip test for issue #17976 if /dev/null is not available. http://hg.python.org/cpython/rev/237deaf9ba64 -- ___ Python tracker

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thank you Jaakko Moisio for your report and patch. -- resolution: -> fixed stage: commit review -> committed/rejected status: open -> closed ___ Python tracker _

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread Roundup Robot
Roundup Robot added the comment: New changeset 33c27b76a4d0 by Serhiy Storchaka in branch '2.7': Issue #17976: Fixed potential problem with file.write() not detecting IO error http://hg.python.org/cpython/rev/33c27b76a4d0 -- nosy: +python-dev ___ Pyth

[issue17976] file.write doesn't raise IOError when it should

2013-12-17 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: LGTM. But err_flag is not needed, valid error numbers are all nonzero. -- assignee: -> serhiy.storchaka stage: needs patch -> commit review ___ Python tracker __

[issue17976] file.write doesn't raise IOError when it should

2013-05-20 Thread Jaakko Moisio
Jaakko Moisio added the comment: > The test pass with Python 3 which does not use the "FILE*" API > anymore. So you should maybe migrate to Python 3 :-) Yes. I will eventually. But not all the libraries I'm using are migrated yet. -- Added file: http://bugs.python.org/file30317/fileobje

[issue17976] file.write doesn't raise IOError when it should

2013-05-17 Thread STINNER Victor
STINNER Victor added the comment: Attached: Test expressed as an unit test, test_dev_null.py. The test pass with Python 3 which does not use the "FILE*" API anymore. So you should maybe migrate to Python 3 :-) $ python3.4 test_dev_null.py .. ---

[issue17976] file.write doesn't raise IOError when it should

2013-05-15 Thread Jaakko Moisio
Jaakko Moisio added the comment: > I tried to reply to the review of my last patch but this tracker > software itself crashed. Is there anyone who would be interested in > the traceback? Never mind. I found the meta tracker and posted my traceback there. --

[issue17976] file.write doesn't raise IOError when it should

2013-05-15 Thread Jaakko Moisio
Jaakko Moisio added the comment: I tried to reply to the review of my last patch but this tracker software itself crashed. Is there anyone who would be interested in the traceback? Anyway, I'll reply here. On 2013/05/15 08:37:29, Charles-François Natali wrote: > http://bugs.python.org/review/1

[issue17976] file.write doesn't raise IOError when it should

2013-05-15 Thread Jaakko Moisio
Changes by Jaakko Moisio : Added file: http://bugs.python.org/file30266/fileobject-fix4.patch ___ Python tracker ___ ___ Python-bugs-list mail

[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Jaakko Moisio
Jaakko Moisio added the comment: > Yeah, would you like to write a patch? Yes. It's fileobject-fix3.patch attached to this issue record. -- Added file: http://bugs.python.org/file30262/fileobject-fix3.patch ___ Python tracker

[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Charles-François Natali
Charles-François Natali added the comment: > 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

[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Jaakko Moisio
Jaakko Moisio added the comment: 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 becaus

[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Charles-François Natali
Charles-François Natali added the comment: > 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 surpri

[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: Yuck. We can of course workaround this (the glibc is commonly used :-)). Why is ferror() not reliable? -- priority: normal -> low stage: -> needs patch ___ Python tracker ___

[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Charles-François Natali
Charles-François Natali added the comment: > Indeed, fwrite() can return expected number of items and set errno. Here is a > simple example on C. An output is: Yeah, who's volunteering to report it to the glibc? That's not a python bug, but I feel bad ignoring it. Note that ferror() isn't rel

[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Indeed, fwrite() can return expected number of items and set errno. Here is a simple example on C. An output is: setvbuf 0 0 fwrite 5 0 fwrite 1 28 fwrite 1 28 On writing "\n" fwrite returns 1 and set errno to ENOSPC. -- nosy: +serhiy.storchaka Adde

[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Charles-François Natali
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 "", line 1, in IOError

[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Jaakko Moisio
New submission from Jaakko Moisio: file.write doesn't sometimes raise IOError when it should, e.g. writing to /dev/full in line buffered mode: jaakko@jm-laptop:~$ python Python 2.7.5+ (2.7:a32a3b79f5e8, May 14 2013, 14:20:11) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "licens