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 vstinner
Recipients luch, pitrou, r.david.murray, vstinner
Date 2011-02-02.16:05:45
SpamBayes Score 1.2607658e-09
Marked as misclassified No
Message-id <1296662747.77.0.975316144289.issue11098@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-02-02 16:05:47vstinnersetrecipients: + vstinner, pitrou, r.david.murray, luch
2011-02-02 16:05:47vstinnersetmessageid: <1296662747.77.0.975316144289.issue11098@psf.upfronthosting.co.za>
2011-02-02 16:05:45vstinnerlinkissue11098 messages
2011-02-02 16:05:45vstinnercreate