This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ftplib bails out on empty responses
Type: Stage:
Components: Extension Modules Versions:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: calvin, loewis
Priority: normal Keywords:

Created on 2002-11-11 17:09 by calvin, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (5)
msg13187 - (view) Author: Bastian Kleineidam (calvin) Date: 2002-11-11 17:09
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
msg13188 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-11-12 15:22
Logged In: YES 
user_id=21627

Can you please explain in what case the server is supposed
to send an empty response?
msg13189 - (view) Author: Bastian Kleineidam (calvin) Date: 2002-11-12 15:58
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
msg13190 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-11-12 16:36
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.
msg13191 - (view) Author: Bastian Kleineidam (calvin) Date: 2002-12-22 00:29
Logged In: YES 
user_id=9205

I got no more input from the user who reported this bug, so I am
unable to reproduce it.
Its ok for me to close this bug.
History
Date User Action Args
2022-04-10 16:05:53adminsetgithub: 37455
2002-11-11 17:09:26calvincreate