[Patches] [ python-Patches-1664522 ] Fix for urllib.ftpwrapper.retrfile() and none existing files

SourceForge.net noreply at sourceforge.net
Thu Mar 29 12:46:59 CEST 2007


Patches item #1664522, was opened at 2007-02-20 18:33
Message generated for change (Comment added) made by pknirsch
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1664522&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Phil Knirsch (pknirsch)
Assigned to: Nobody/Anonymous (nobody)
Summary: Fix for urllib.ftpwrapper.retrfile() and none existing files

Initial Comment:
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

----------------------------------------------------------------------

>Comment By: Phil Knirsch (pknirsch)
Date: 2007-03-29 12:46

Message:
Logged In: YES 
user_id=1724367
Originator: YES

Anyone looking at this? ;)

Read ya, Phil

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1664522&group_id=5470


More information about the Patches mailing list