[issue41737] Improper NotADirectoryError when opening a file in a fake directory

Danny Lin report at bugs.python.org
Tue Oct 20 10:36:13 EDT 2020


Danny Lin <danny0838 at gmail.com> added the comment:

I don't think a general developer would expect that open('/path/to/file/somename.txt') implies a directory operation, and it also doesn't on Windows.

I suggest that a further notice be added to NotADirectoryError, such as:

    Raised when a directory operation (such as os.listdir()) is requested on something which is not a directory. Corresponds to errno ENOTDIR. In some filesystem such as POSIX, NotADirectoryError (ENOTDIR) is raised when attempting to open a path whose ancestor is not a directory.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41737>
_______________________________________


More information about the Python-bugs-list mailing list