Danny Lin <[email protected]> added the comment:
I'm not so familiar about the spec. If such behavior is confirmed due to
implementation difference across OSes, and it's also not desirable to change
the mapping of the OS error to Python exception, we can simplify left it as-is.
However, this behavior difference can potentially cause cross-platform
compatibility. For example, the code:
try:
open('/path/to/file/somename.txt')
except FileNotFoundError:
"""do something"""
would work on Windows but break on Linux (or POSIX?).
The current (3.8) description for exception NotADirectoryError is:
Raised when a directory operation (such as os.listdir()) is requested on
something which is not a directory. Corresponds to errno ENOTDIR.
According to this, a user probably won't expect to receive a NotADirectoryError
for open('/path/to/file/somename.txt'), as this doesn't seem like a directory
operation at all, unless he is expert enough to know about the implication of
errno ENOTDIR.
I think a note should at least be added to the documentation if we are not
going to change the behavior.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue41737>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com