CGI python 3 write RAW BINARY

Dodo dodo_do_not_wake_up at yahoo.Fr
Thu Apr 29 17:37:32 EDT 2010


Le 29/04/2010 22:21, Antoine Pitrou a écrit :
> Le Thu, 29 Apr 2010 18:33:08 +0200, Dodo a écrit :
>> Oh, I tested on my windows machine avec sys.stdout.buffer.write() didn't
>> work.
>> I just tested on my linux server, and it works....
>>
>> So, let's modify the script
>>
>> 		sys.stdout.buffer.write( f.read() )
>> 		sys.stdout.flush()
>
> Sorry, I should have been clearer. You have to flush sys.stdout before
> using sys.stdout.buffer, such that the unicode layer doesn't keep any
> unwritten data. So this should be:
>
> 		sys.stdout.flush()
> 		sys.stdout.buffer.write( f.read() )
>
> Regards
>
> Antoine.
>

....I don't get a thing.
Now with the fix :
All browsers shows a different thing, but not the image!
http://ddclermont.homeip.net/misc/python/

If I save it to computer :
* Windows image viewer won't read it
* Irfanview can read it without problems

Dorian

PS : ça commence sérieusement à m'énerver



More information about the Python-list mailing list