W95 binary output from CGI script

Tim Peters tim_one at email.msn.com
Wed Jun 23 01:14:31 EDT 1999

[Tom Hall]
> I'm working on a CGI script for Windows 95, and trying to send
> binary data out stdout. Every time I try to send a \x0a it spits
> out \x0d\x0a.

Python opens the std file streams in text mode, and under all flavors of
Windows that does horrible stuff to binary data.  Quoting from a different

[Charles G Waldman]
> Try running Python in unbuffered mode - with a "-u" commandline flag,
> or by setting the PYTHONUNUFFERED environment variable to a non-empty
> string.

That disables buffering, but under Windows it also causes Python to open the
std streams in binary mode.

blame-niklaus-wirth-cuz-bill-gates-is-untouchable-ly y'rs  - tim

More information about the Python-list mailing list