[issue32345] EIO from write() is only fatal if print() contains a newline

2017-12-25 Thread STINNER Victor
Change by STINNER Victor : -- nosy: +vstinner ___ Python tracker ___ ___

[issue32345] EIO from write() is only fatal if print() contains a newline

2017-12-20 Thread Creideiki
Creideiki added the comment: I ran this program: #include #include #include #include void print(const char *s, size_t l) { errno = 0; fwrite(s, l, 1, stdout); int saved_errno = errno; fprintf(stderr, "After \"%s\": ferror(): %i,

[issue32345] EIO from write() is only fatal if print() contains a newline

2017-12-20 Thread Antoine Pitrou
Antoine Pitrou added the comment: I think the difference here is that Python calls ferror() to tell whether an error occurred on the underlying FILE*. Can you adapt your C program to check ferror()? -- ___ Python tracker

[issue32345] EIO from write() is only fatal if print() contains a newline

2017-12-20 Thread Creideiki
print('E') print('B\nC') print('D') write(1, "A\n", 2) = -1 EIO (Input/output error) write(1, "E\n", 2) = -1 EIO (Input/output error) write(1, "B\n", 2) = -1 EIO (Input/output error) write(2, "Traceba

[issue32345] EIO from write() is only fatal if print() contains a newline

2017-12-19 Thread Antoine Pitrou
Antoine Pitrou added the comment: Python 2 doesn't call write(), it calls fwrite() and friends (i.e. it uses the libc's buffered I/O API). Also we don't do anything special if the printed string has a newline in it. So my guess is that it's a bug in the libc. --

[issue32345] EIO from write() is only fatal if print() contains a newline

2017-12-16 Thread Creideiki
ahflee/torbrowser-launcher/issues/298 It seems the cause is that a print() call without a newline ignores the EIO returned by the write() syscall, but if there is a newline in the string, that EIO is suddenly a fatal error. Reproducer: $ cat fatal.py #!/bin/env python2.7 import time time.s

Re: print() with no newline

2016-12-18 Thread ElChino
Chris Warrick wrote: >> I'm getting a syntax error in Python2. Python3 is fine. >> How can I make this Py2+3 compatible? > > With a __future__ import, the Python 3 syntax will work with both Pythons: > > from __future__ import print_function > print(s, end="") Thanks. Lovely. --

Re: print() with no newline

2016-12-18 Thread Chris Warrick
On 18 December 2016 at 13:25, ElChino wrote: > In this snippet: > import sys > PY3 = (sys.version_info[0] >= 3) > > def print_no_nl (s): > if PY3: > print (s, end="") > else: > print (s), > > I'm getting a syntax error in Python2. Python3 is fine. > How

print() with no newline

2016-12-18 Thread ElChino
In this snippet: import sys PY3 = (sys.version_info[0] >= 3) def print_no_nl (s): if PY3: print (s, end="") else: print (s), I'm getting a syntax error in Python2. Python3 is fine. How can I make this Py2+3 compatible? --