Eryk Sun <eryk...@gmail.com> added the comment:

Regarding documentation, builtin open() and the io and os modules generally do 
not provide information about platform-specific errors. But documenting the 
behavior for the NotADirectoryError exception itself may be useful considering 
it applies to many POSIX functions that access filepaths, such as stat, open, 
mkdir, rmdir, unlink, and rename.

Regarding behavior, I don't see anything reasonable that can or should be done 
for POSIX. In Windows, it should be possible to know whether FileNotFoundError 
is due to a bad path prefix (ERROR_PATH_NOT_FOUND, 3) or a missing file 
(ERROR_FILE_NOT_FOUND, 2), but io.FileIO currently only uses standard C errno, 
which maps both of these cases to ENOENT. So one behavior that *can* be fixed 
in this situation is to get the actual Windows error code from MSVC _doserrno, 
such that the raised FileNotFoundError would have the relevant Windows error 
code in its winerror attribute.

----------

_______________________________________
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

Reply via email to