Issue 636685: ftplib bails out on empty responses (original) (raw)

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 ' 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

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.