Sam Adams added the comment: Silent: The issue that i see is how the error is handled. I can trap the TypeError easily, however, if I keep the socket open, the behavior of ftplib will not be as intended. For example:
fileTest = open('filename1', 'wb') ftp.retrlines('RETR README.html', fileTest.write) This will give a TypeError, as intended However, what happens next is, I believe, not intended -- If i send a command after this trapped error, say, ftp.sendcmd('NOOP') The result will not be 200 NOOP command successful but, instead, 226 Transfer Complete As the previous status was not read from the file created by the socket, so if i want to try and do anything for the user after, the message received, and subsequently parsed by the getresp function, will not be the message that is expected. For a noop command this is ok, but for a transfer command, it will set the mode to either A or I and return a 200 status when a different status was expected. This will raise an error. The only way to fix this is to either run the internal function getline() or reset the connection, thus clearing all messages from the file. I have attached a file that has a fix, Im not sure if this is helpful or not. I modified the retrbinary function on lines: 440,449-450,454-455 I also modified the retrlines function on lines: 470,490-491,496-497 ---------- Added file: http://bugs.python.org/file41400/ftplib.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25933> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com