Issue 1470976: Fix for urllib/urllib2 ftp bugs 1357260 and 1281692 (original) (raw)

This fixes 1357260 and 1281692.

As suggested in the initial comment for 1357260, the patch simply removes the code that does an NLST before the attempt to actually fetch the file, since some server operators turn off file listing (presumably in an attempt to provide increased security of some kind). "Easier to ask forgiveness than get permission" applies to the FTP protocol as much as to Python :-)

FWIW, I verified that this allows retrieval in some cases where it wasn't previously, using proftpd 1.2.10 (gentoo ebuild r7) with this configuration directive placed inside the <Anonymous ~ftp> directive:

<Limit LIST NLST>
  DenyAll
</Limit>

Without the patch, I get a 450 when doing a urlopen on files accessible from that server (using either urllib or urllib2). With the patch, I can retrieve the files.