[Patches] [ python-Patches-553277 ] Little ftplib bug

noreply@sourceforge.net noreply@sourceforge.net
Tue, 07 May 2002 07:02:56 -0700


Patches item #553277, was opened at 2002-05-07 16:02
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=553277&group_id=5470

Category: Library (Lib)
Group: Python 2.2.x
Status: Open
Resolution: None
Priority: 5
Submitted By: Geert Jansen (geertj)
Assigned to: Nobody/Anonymous (nobody)
Summary: Little ftplib bug

Initial Comment:
There seem to be a little bug in FTP.retrlines in the 
module ftplib in the standard library. In this 
function, the default value for the "callback" 
parameter is None. The absence of a callback parameter 
is tested in the body if the function with "if not 
callback:". 

This gives problems in real-life when you're using a 
callable container class as the callback function. 
When the container is empty (__len__  returns 0), the 
test "if not callback:" is true and a default callback 
is used instead of the user supplied one.

The fix is to change the test "if not callback" to "if 
callback is None:". One-line patch attached.

Greetings,
Geert Jansen

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=553277&group_id=5470