# HG changeset patch # Parent cb612c5f30cb5fad03200b8d56b160172a5c4a22 diff -r cb612c5f30cb Modules/selectmodule.c --- a/Modules/selectmodule.c Thu Nov 15 18:22:23 2012 +0000 +++ b/Modules/selectmodule.c Mon Dec 03 19:56:18 2012 +0000 @@ -48,8 +48,16 @@ #endif #ifdef MS_WINDOWS +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0600 +# undef NTDDI_VERSION +# define NTDDI_VERSION NTDDI_LONGHORN # define WIN32_LEAN_AND_MEAN -# include +# include +# include +# define HAVE_POLL +# define poll(fds, nfds, timeout) WSAPoll((fds), (ULONG)(nfds), (timeout)) + /* On Windows registering with the POLLPRI flag always fails */ #else # define SOCKET int # if defined(__VMS) @@ -371,7 +379,12 @@ poll_register(pollObject *self, PyObject *args) { PyObject *o, *key, *value; +#ifndef MS_WINDOWS int fd, events = POLLIN | POLLPRI | POLLOUT; +#else + /* Requesting the POLLPRI event fails on Windows */ + int fd, events = POLLIN | POLLOUT; +#endif int err; if (!PyArg_ParseTuple(args, "O|i:register", &o, &events)) { @@ -530,7 +543,11 @@ Py_END_ALLOW_THREADS if (poll_result < 0) { +#ifndef MS_WINDOWS PyErr_SetFromErrno(PyExc_OSError); +#else + PyErr_SetFromWindowsErr(WSAGetLastError()); +#endif return NULL; } @@ -551,7 +568,11 @@ value = PyTuple_New(2); if (value == NULL) goto error; +#ifndef MS_WINDOWS num = PyLong_FromLong(self->ufds[i].fd); +#else + num = PyLong_FromSsize_t((Py_ssize_t)self->ufds[i].fd); +#endif if (num == NULL) { Py_DECREF(value); goto error;