From: Guido van Rossum Date: Thu, 6 Aug 1998 03:23:32 +0000 (+0000) Subject: In Win32 version of listdir(), when FindFirstFile() returns X-Git-Tag: v1.5.2a1~134 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=617bc19e3d7911c478e8313e59a702b99ab440f7;p=python In Win32 version of listdir(), when FindFirstFile() returns ERROR_FILE_NOT_FOUND, return an empty list instead of raising an exception. --- diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 6708df8d81..8174890dd5 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -644,6 +644,8 @@ posix_listdir(self, args) hFindFile = FindFirstFile(namebuf, &FileData); if (hFindFile == INVALID_HANDLE_VALUE) { errno = GetLastError(); + if (errno == ERROR_FILE_NOT_FOUND) + return PyList_New(0); return posix_error(); } do {