On Dec 14, 6:58 pm, Cameron Walsh <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Using a pythoncgiscript such as the one below to handle uploaded
> binary files will end up with atruncatedfile (truncates when it hits
> ^Z) on Windows systems.  On linux systems the code works and the file is
> nottruncated.
>
> One solution for Windows is to use the -u flag, i.e.
> #!C:\Python\python.exe -u
>
> Is there another fix that doesn't require python to be run in unbuffered
> mode?  What performance hits would I expect for running in unbuffered mode?

Answer to the first part:

import msvcrt, sys, os
msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)

# other problems may also be fixed with:
# msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)

Cameron.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to