[Image-SIG] StringIO seems to garble images in cgi

Fredrik Lundh fredrik@pythonware.com
Mon, 9 Dec 2002 00:01:47 +0100


jack wrote:

> As you're using normal write() calls to sys.stdout you'll be messing up 
> your \r and \n bytes in the image: sys.stdout is a text-mode file so 
> you can't write binary data to it. At least: not on Windows.

on Windows, the "-u" option sets the output to binary mode:

C:/> python -?
...
-u     : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
...

</F>