summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-04-06 21:06:01 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-04-06 21:06:01 (GMT)
commit9001d8089cf1632680a838b44697cb3339e40dce (patch)
tree3482321928bdc524a11504adaea0422b18bced31 /Modules
parent62aa7dc7c9b279df9bfd23c3553b1c27725dc76b (diff)
downloadcpython-9001d8089cf1632680a838b44697cb3339e40dce.zip
cpython-9001d8089cf1632680a838b44697cb3339e40dce.tar.gz
cpython-9001d8089cf1632680a838b44697cb3339e40dce.tar.bz2
Issue #23834: Fix initial value of the socket timeout
Use _PyTime_FromSeconds() to initialize the default socket timeout to -1 second, instead of -1 nanosecond which causes rounding issues in internal_select().
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 5e267a4..604b9a8 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -2292,7 +2292,7 @@ sock_setblocking(PySocketSockObject *s, PyObject *arg)
if (block == -1 && PyErr_Occurred())
return NULL;
- s->sock_timeout = block ? -1 : 0;
+ s->sock_timeout = _PyTime_FromSeconds(block ? -1 : 0);
internal_setblocking(s, block);
Py_INCREF(Py_None);
@@ -4162,7 +4162,7 @@ sock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
new = type->tp_alloc(type, 0);
if (new != NULL) {
((PySocketSockObject *)new)->sock_fd = -1;
- ((PySocketSockObject *)new)->sock_timeout = -1;
+ ((PySocketSockObject *)new)->sock_timeout = _PyTime_FromSeconds(-1);
((PySocketSockObject *)new)->errorhandler = &set_error;
}
return new;