summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Henry <[email protected]>2021-05-30 21:49:16 -0700
committerJoseph Henry <[email protected]>2021-05-30 21:49:16 -0700
commitd49667a55f259f27bcfc670e9a7214e58691ed2c (patch)
treeebcc7158fd1f1801cad431c4c1fd3f51891543b4
parent50d99aca9875d156d8c59e49b254dcfce37f3356 (diff)
Check Python version to determine proper timeout rounding mode1.4.2
-rw-r--r--src/bindings/python/PythonSockets.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bindings/python/PythonSockets.cxx b/src/bindings/python/PythonSockets.cxx
index 2560fea..ca6d8e1 100644
--- a/src/bindings/python/PythonSockets.cxx
+++ b/src/bindings/python/PythonSockets.cxx
@@ -327,13 +327,18 @@ PyObject* zts_py_select(PyObject* module, PyObject* rlist, PyObject* wlist, PyOb
tvp = (struct timeval*)NULL;
}
else {
- if (_PyTime_FromSecondsObject(&timeout, timeout_obj, _PyTime_ROUND_UP) < 0) {
+#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION <= 5
+ _PyTime_round_t roundingMode = _PyTime_ROUND_CEILING;
+#else
+ _PyTime_round_t roundingMode = _PyTime_ROUND_UP;
+#endif
+ if (_PyTime_FromSecondsObject(&timeout, timeout_obj, roundingMode) < 0) {
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
PyErr_SetString(PyExc_TypeError, "timeout must be a float or None");
}
return NULL;
}
- if (_PyTime_AsTimeval(timeout, &tv, _PyTime_ROUND_UP) == -1) {
+ if (_PyTime_AsTimeval(timeout, &tv, roundingMode) == -1) {
return NULL;
}
if (tv.tv_sec < 0) {