Opened 4 weeks ago

Closed 3 weeks ago

#148 closed defect (fixed)

Wrong query results for empty path

Reported by: schwa Owned by: schwa
Priority: minor Milestone: 5.0.2
Component: Library Version: 5.0.1
Keywords: empty path, absolute path Cc:


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

Change History (3)

comment:1 Changed 4 weeks ago by schwa

Keywords: empty path absolute path added
Milestone: 5.0.2

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 return False whereas probably should raise a PermanentError.

comment:2 Changed 4 weeks ago by schwa

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 "".

comment:3 Changed 3 weeks ago by schwa

Resolution: fixed
Status: newclosed
  • FTPHost.path.isdir, isfile and islink now return False for an empty path.
  • Most public methods raise an FTPIOError for an empty path. The exception is FTPHost.chdir. The reason is explained in commit [f3cbaa1dbc21].
Note: See TracTickets for help on using tickets.