ftplib possible bug? Please help.

Chris Barker chrishbarker at home.net
Mon Jun 18 21:55:59 CEST 2001

Marshall wrote:
> I am using Python 2.0 on NT 4.0
> When I ftp a file from one NT server to another, using ftplib, it
> changes the end of the line from CRLF to LF. It does this EVEN when
> the transfer is Binary.
> Passive mode or not passive does not make a difference either.
> Is this a known problem? and is there a fix?

make sure you are opening your files as binary files, i.e.:

file = open(filename, "rb")

If you leave the "b" out, the CRLF will get translated to LF when Python
reads the file. It will then get send by ftplib tot he server without
any additional translation. I made this mistake, and it worked fine on
Linux, and broke on the Mac, and it took me along time to find it. Duh!


Christopher Barker,
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------

More information about the Python-list mailing list