[Python-checkins] cpython: Issue #14180: Fix the select module to handle correctly the Windows timeval
victor.stinner
python-checkins at python.org
Wed Mar 14 00:20:39 CET 2012
http://hg.python.org/cpython/rev/a0d101220f96
changeset: 75613:a0d101220f96
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Mar 14 00:20:51 2012 +0100
summary:
Issue #14180: Fix the select module to handle correctly the Windows timeval
structure. timeval.tv_sec is a long on Windows, not time_t.
files:
Modules/selectmodule.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -223,10 +223,23 @@
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;
- tv.tv_usec = usec;
+ 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;
+ }
+#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;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list