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 pknirsch
Recipients
Date 2007-02-20.17:33:00
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
When trying to retrieve a none existing file using the urllib.ftpwrapper.retrfile() method the behaviour is that instead of an error message a valid hook is returned and you will recieve a 0 byte file.

The current behaviour tries to emulate what one typically sees with http servers and DirIndexes, which means:

1) Try to RETR the file.
2) If that fails, assume it is a directory and LIST it.

Unfortunately it doesn't actually check whether the directory actually exists.

The attached patch fixes this by remembering the current directory using the PWD command, then temporarily change to that directory and switch back to the previous working directory if it was successfull.

If not we raise an IO error, as the file could neither be opened (RETR) nor was it a directory.

That way the behaviour is even closer to what happens with http servers where we get a 404 when we try to access a none existing file or directory.

Storing the current directory and switching back to it in case of no error will also put the connection back in the proper state and directory, so no unexpected behaviour happens here.

The patch is against the current SVN repository at revision 53833.

Read ya, Phil
History
Date User Action Args
2007-08-23 15:56:37adminlinkissue1664522 messages
2007-08-23 15:56:37admincreate