pyfilesystem
pyfilesystem copied to clipboard
convert_fs_error raises (possibly) incorrect exception.
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 [email protected] on 14 Nov 2012 at 8:13
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