bad data from urllib when run from MS .bat file

John J. Lee jjl at
Sun Sep 19 22:25:33 CEST 2004

"Stuart McGraw" <smcg4191 at> writes:
> 2. Create a batch file that will run
> test.bat:
> ----------------
> python
> ----------------
> 3. In a cmd.exe window run the following two commands:
>   python >out1.txt
>   test.bat >out2.txt
> 4. out1.txt and out2.txt should be identical.  But they are not.
> Running with a debugger shows that the corruption is in the text 
> received from urllib; it is not a result of the euc-jp decoding,
> UTF-8 encoding, or writing to the output file.


> So it looks like some bad mojo between urllib and the Windows
> batch environment.

Just a guess, without actually bothering to think about the numerology
in detail:

python -u

Note the -u switch (for 'unbuffered', but also 'um, binary mode'


More information about the Python-list mailing list