piranna / pyfilesystem

Automatically exported from code.google.com/p/pyfilesystem
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

convert_fs_error raises (possibly) incorrect exception. #138

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

@convert_fs_errors
def test():
    return fs.open('/foo/bar', 'r')

What is the expected output? What do you see instead?

Assuming /foo/bar does not exist, This function will raise an 
OSError(errno.ENOENT). Python (at least 2.7) raises an IOError for this case.

The Python documentation specifically mentions "file not found" errors in 
relation to IOError.

http://docs.python.org/2/library/exceptions.html#exceptions.IOError

Also, the following code raises an IOError.

def test():
    return file('/foo/bar', 'r')

I mention this because of the integration with pyftpdlib (export/ftp.py). The 
FTP daemon code expects an IOError not an OSError. The options are to either 
modify convert_fs_errors, or I can write another wrapper for the ftp 
integration that converts the exception type for this case.

Original issue reported on code.google.com by btimby@gmail.com on 14 Nov 2012 at 8:13

GoogleCodeExporter commented 9 years ago
Please note that starting from not sure what version pyftpdlib catches a more 
generic EnvironmentError so this should no longer be a problem with pyftpdlib 
integration per-se.

Original comment by g.rodola on 17 Apr 2013 at 11:34