Message127739
Since r7409 (14 years ago), Python does set the binary binary mode on stdin and stdout (not stderr) if the -u flag is used:
----
if (unbuffered) {
#if defined(MS_WINDOWS) || defined(__CYGWIN__)
_setmode(fileno(stdin), O_BINARY);
_setmode(fileno(stdout), O_BINARY);
#endif
#ifdef HAVE_SETVBUF
setvbuf(stdin, (char *)NULL, _IONBF, BUFSIZ);
setvbuf(stdout, (char *)NULL, _IONBF, BUFSIZ);
setvbuf(stderr, (char *)NULL, _IONBF, BUFSIZ);
#else /* !HAVE_SETVBUF */
setbuf(stdin, (char *)NULL);
setbuf(stdout, (char *)NULL);
setbuf(stderr, (char *)NULL);
#endif /* !HAVE_SETVBUF */
}
----
If you would like to check that the problem is related to the binary mode, you can set the binary mode manually without the -u flag. Add the following code at the end of your site.py file:
----
import msvcrt
msvcrt.setmode (0, os.O_BINARY) # stdin = 0
msvcrt.setmode (1, os.O_BINARY) # stdout = 1
msvcrt.setmode (2, os.O_BINARY) # stderr = 2
----
Python 3.2 does always set the binary mode for all files (opened files but also stdin, stdout and stderr), which requires a fix in the parser because the parser didn't support Windows newlines (\r\n). See issue 10841 and the commit r87824 for more information. |
|
Date |
User |
Action |
Args |
2011-02-02 16:05:47 | vstinner | set | recipients:
+ vstinner, pitrou, r.david.murray, luch |
2011-02-02 16:05:47 | vstinner | set | messageid: <1296662747.77.0.975316144289.issue11098@psf.upfronthosting.co.za> |
2011-02-02 16:05:45 | vstinner | link | issue11098 messages |
2011-02-02 16:05:45 | vstinner | create | |
|