A user reported that several FTPHost
methods return wrong results when
given an empty path, for example
FTPHost.path.exists("")
-> True
FTPHost.path.isdir("")
-> True
The reason for the odd behavior is that all the
FTPHost
methods immediately change a path argument to an absolute path without checking the argument beforehand. Therefore, turning""
into an absolute path always gives the absolute path of the current directory.To fix this problem, the incoming path should be compared against
""
and if that's the value, the path should be considered non-existent, or an exception should be raised. The behavior will depend on the concrete method. For example,FTPHost.path.exists
should returnFalse
whereasFTPHost.open
probably should raise aPermanentError
.
For the record: Curiously, using an empty path under Linux on an ext4 file system results in a "file not found" error, even when creating a file, for example with
touch ""
.
FTPHost.path.isdir
,isfile
andislink
now returnFalse
for an empty path.- Most public methods raise an
FTPIOError
for an empty path. The exception isFTPHost.chdir
. The reason is explained in commit d615279cd0f7dfc560f9b4eac3bd88572d25750b.