summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-03-13 23:20:51 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-03-13 23:20:51 (GMT)
commitb2a37733017c4a469147d00d539e5313afc19340 (patch)
treeb892855aba1fd9b3ebdfc888fe86fe35730fbbde /Modules
parent8050ca9c6f614d2beb47cc1b53d73f3721f57c8f (diff)
downloadcpython-b2a37733017c4a469147d00d539e5313afc19340.zip
cpython-b2a37733017c4a469147d00d539e5313afc19340.tar.gz
cpython-b2a37733017c4a469147d00d539e5313afc19340.tar.bz2
Issue #14180: Fix the select module to handle correctly the Windows timeval
structure. timeval.tv_sec is a long on Windows, not time_t.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/selectmodule.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index 19d9d3b..9cb7481 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -223,10 +223,23 @@ select_select(PyObject *self, PyObject *args)
return NULL;
}
else {
- long usec;
- if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &usec) == -1)
+#ifdef MS_WINDOWS
+ time_t sec;
+ if (_PyTime_ObjectToTimeval(tout, &sec, &tv.tv_usec) == -1)
+ return NULL;
+ assert(sizeof(tv.tv_sec) == sizeof(long));
+#if SIZEOF_TIME_T > SIZEOF_LONG
+ if (sec > LONG_MAX) {
+ PyErr_SetString(PyExc_OverflowError,
+ "timeout is too large");
return NULL;
- tv.tv_usec = usec;
+ }
+#endif
+ tv.tv_sec = (long)sec;
+#else
+ if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv.tv_usec) == -1)
+ return NULL;
+#endif
if (tv.tv_sec < 0) {
PyErr_SetString(PyExc_ValueError, "timeout must be non-negative");
return NULL;