]> granicus.if.org Git - python/commitdiff
In Win32 version of listdir(), when FindFirstFile() returns
authorGuido van Rossum <guido@python.org>
Thu, 6 Aug 1998 03:23:32 +0000 (03:23 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 6 Aug 1998 03:23:32 +0000 (03:23 +0000)
ERROR_FILE_NOT_FOUND, return an empty list instead of raising an
exception.

Modules/posixmodule.c

index 6708df8d81252ceea81b33dfc8bf506c435bedee..8174890dd53813c59a6c5814a20d2ff0e05f17d1 100644 (file)
@@ -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 {