This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author danny87105
Recipients danny87105, eryksun
Date 2020-09-08.10:24:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1599560690.25.0.207502419704.issue41737@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-09-08 10:24:50danny87105setrecipients: + danny87105, eryksun
2020-09-08 10:24:50danny87105setmessageid: <1599560690.25.0.207502419704.issue41737@roundup.psfhosted.org>
2020-09-08 10:24:50danny87105linkissue41737 messages
2020-09-08 10:24:49danny87105create