]> granicus.if.org Git - python/commitdiff
On Windows, call WSAGetLastError() to retrieve the error number.
authorThomas Heller <theller@ctypes.org>
Tue, 24 Sep 2002 16:51:00 +0000 (16:51 +0000)
committerThomas Heller <theller@ctypes.org>
Tue, 24 Sep 2002 16:51:00 +0000 (16:51 +0000)
Bugfix candidate, will backport to release22-maint myself.

Modules/selectmodule.c

index 2caa0225f4c5ed7c0bdc78db6d67f7134fa66043..8444c12adda71bc76962820986e50ca1872c21b8 100644 (file)
@@ -39,7 +39,7 @@ extern void bzero(void *, int);
 #endif
 
 #ifdef MS_WINDOWS
-#include <winsock.h>
+#include <windows.h>
 #else
 #ifdef __BEOS__
 #include <net/socket.h>
@@ -273,9 +273,15 @@ select_select(PyObject *self, PyObject *args)
        n = select(max, &ifdset, &ofdset, &efdset, tvp);
        Py_END_ALLOW_THREADS
 
+#ifdef MS_WINDOWS
+       if (n == SOCKET_ERROR) {
+               PyErr_SetExcFromWindowsErr(SelectError, WSAGetLastError());
+       }
+#else
        if (n < 0) {
                PyErr_SetFromErrno(SelectError);
        }
+#endif
        else if (n == 0) {
                 /* optimization */
                ifdlist = PyList_New(0);