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.

Author Sam Adams
Recipients Sam Adams, SilentGhost, r.david.murray
Date 2015-12-24.02:07:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1450922867.78.0.389645259953.issue25933@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2015-12-24 02:07:50Sam Adamssetrecipients: + Sam Adams, r.david.murray, SilentGhost
2015-12-24 02:07:47Sam Adamssetmessageid: <1450922867.78.0.389645259953.issue25933@psf.upfronthosting.co.za>
2015-12-24 02:07:47Sam Adamslinkissue25933 messages
2015-12-24 02:07:47Sam Adamscreate