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

2017-06-21 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- resolution: -> not a bug stage: test needed -> resolved status: open -> closed ___ Python tracker ___

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

2017-06-18 Thread Eryk Sun
Eryk Sun added the comment: Yes, I think this issue should be closed. But for the record I'd like to note a not uncommon case in which listdir() raise FileNotFoundError on Windows. According to MS-FSA [1], if a request to open a directory resolves to a file, the operation should fail with

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

2017-06-18 Thread Terry J. Reedy
Terry J. Reedy added the comment: Eryk, does your last comment suggest that we close this? -- ___ Python tracker ___

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

2017-01-28 Thread Eryk Sun
Eryk Sun added the comment: Python has no specific use for ERROR_PATH_NOT_FOUND (3) and just maps it to FileNotFoundError -- like the CRT maps it to ENOENT. Even if we wanted listdir() to specially handle this error, given that it's implemented via FindFirstFile, there's nothing that can be

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

2017-01-27 Thread Terry J. Reedy
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,

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

2017-01-26 Thread Eryk Sun
Eryk Sun added the comment: > FindFirstFile naturally fails with ERROR_PATH_NOT_FOUND Getting this error actually depends on the file system. I don't see it with NTFS, which returns STATUS_NOT_A_DIRECTORY, which gets translated to ERROR_DIRECTORY. On the other hand, VboxSF (VirtualBox shared

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

2017-01-25 Thread Eryk Sun
Eryk Sun added the comment: Python appends "\*.*" to the path, so in the case in which the leaf element is a file, FindFirstFile naturally fails with ERROR_PATH_NOT_FOUND. Python 3.5+ could maybe switch to calling CreateFile to open a handle and GetFileInformationByHandleEx to get the

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

2017-01-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Blame Windows for this behavior. os.listdir() is just a wrapper around few system calls. It is expected that functions in the os module can raise different exceptions on different platforms. -- nosy: +serhiy.storchaka

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

2017-01-25 Thread raylu
raylu added the comment: os.listdir should always return NotADirectoryError when run on a regular file. Users shouldn't have to special-case win32/FileNotFoundError. -- ___ Python tracker

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

2017-01-25 Thread R. David Murray
R. David Murray added the comment: Could you please clarify what bug you are reporting? -- nosy: +r.david.murray ___ Python tracker ___

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

2017-01-24 Thread raylu
New submission from raylu: According to https://github.com/python/cpython/blob/4ed71dae9d23a412f9f73d3a0b1f4be37543e49e/Lib/test/test_unicode_file_functions.py#L106 listdir can sometimes return FileNotFoundError on Windows. Tangentially related: https://hg.python.org/cpython/rev/385c2ec78f16