[Python-bugs-list] [ python-Bugs-636685 ] ftplib bails out on empty responses

noreply@sourceforge.net noreply@sourceforge.net
Tue, 12 Nov 2002 08:36:28 -0800


Bugs item #636685, was opened at 2002-11-11 18:09
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=636685&group_id=5470

Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Bastian Kleineidam (calvin)
Assigned to: Nobody/Anonymous (nobody)
Summary: ftplib bails out on empty responses

Initial Comment:
In ftplib.py, FTP.getresp(), there is:
if c in '123', and c is the first char of the reponse
line. However, if the
response is empty, then this line will throw an exception:

File "/usr/lib/python2.2/ftplib.py", line 108, in __init__
self.connect(host)
File "/usr/lib/python2.2/ftplib.py", line 133, in connect
self.welcome = self.getresp()
File "/usr/lib/python2.2/ftplib.py", line 216, in getresp
if c not in '123':
TypeError: 'in <string>' requires character as left operand
System info:
LinkChecker 1.6.6
Python 2.2.2 (#4, Oct 15 2002, 04:21:28)
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2 

I suggest you test if c is a character before calling
the if-clause.

Cheers, Bastian

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

>Comment By: Martin v. L÷wis (loewis)
Date: 2002-11-12 17:36

Message:
Logged In: YES 
user_id=21627

I believe the assumption is guaranteed by the FTP protocol.

I think we really need more information here. If you can
come up with a tested patch (i.e. tested by your user, for
this respective server), this might be sufficient to make a
change - but I won't make a change without having understood
all details of the change.

If this is what it looks like (i.e. a protocol violation),
error_proto would be appropriate.

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

Comment By: Bastian Kleineidam (calvin)
Date: 2002-11-12 16:58

Message:
Logged In: YES 
user_id=9205

I dont know which FTP server causes the exception, I already
asked the submitter  to provide more info.
You can find the assorted bug report for this at
http://sourceforge.net/tracker/index.php?func=detail&aid=635596&group_id=1913&atid=101913

Anyway, the ftplib code makes a non-guaranteed assumption
about the response length. I think a solution would be to
throw an ftplib error in case of an empty response.

Cheers, Bastian

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

Comment By: Martin v. L÷wis (loewis)
Date: 2002-11-12 16:22

Message:
Logged In: YES 
user_id=21627

Can you please explain in what case the server is supposed
to send an empty response?

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=636685&group_id=5470