ftplib - Did the whole file get sent?

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Sat Oct 30 04:13:42 CEST 2010

In message <4cc5d9e9$0$1661$742ec2ed at news.sonic.net>, John Nagle wrote:

>     Look at sock_close in "socketmodule.c".  Note that it ignores the
> return status on close, always returns None, and never raises an
> exception.  As the Linux manual page for "close" says:
> "Not checking the return value of close() is a common but nevertheless
> serious programming error. It is quite possible that errors on a
> previous write(2) operation are first reported at the final close(). Not
> checking the return value when closing the file may lead to silent loss
> of data."

The close call is the wrong place to report such errors. For output, there 
should be some kind of flush-output call that you can use to get the error. 
Close should just unconditionally tear down the connection, which you can do 
whether the prior transfers were successful or not.

More information about the Python-list mailing list