[issue29366] os.listdir has inconsistent behavior when run on a non-directory

Terry J. Reedy report at bugs.python.org
Fri Jan 27 14:17:26 EST 2017


Terry J. Reedy added the comment:

This is a feature-change 'enhancement' issue.  There is no violation of the doc at https://docs.python.org/3/library/os.html#os.listdir and as Raylu noted, the current behavior is accommodated in tests.

I presume that regardless of what system calls are made, FileNotFoundError and anything else could be caught and NotADirectoryError raised instead, with the message containing the Windows error message.  This would only break Windows-specific code that only catches FileNotFoundError and not NotADirectoryError.

I am not sure what our general policy is and whether this should be fixed at this point.  I personally like Python smoothing over OS differences when easily possible.

----------
nosy: +terry.reedy
stage:  -> test needed
type:  -> enhancement
versions: +Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29366>
_______________________________________


More information about the Python-bugs-list mailing list