Danny Lin <danny0...@gmail.com> added the comment:
By writing "except FileNotFoundError:", the intention is to catch an error when the file being opened is not found, and don't catch an error for other cases, such as an existing file without adequate permission. Writing "except OSError:" catches just too much cases including unwanted ones. As they are not equivalent, you cannot say that the latter is the "correct" way for the former. And you totally omitted the argument for the inadequate documentation for NotADirectoryError. It says NotADirectoryError is raises when a DIRECTORY operation is requested, and does not cover the case of opening a file. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue41737> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com