File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,12 @@ PyAPI_FUNC(int) _PyTime_ObjectToTimespec(
6767
6868
6969/* Create a timestamp from a number of seconds. */
70- PyAPI_FUNC (_PyTime_t ) _PyTime_FromSeconds (int ns );
70+ PyAPI_FUNC (_PyTime_t ) _PyTime_FromSeconds (int seconds );
71+
72+ /* Macro to create a timestamp from a number of seconds, no integer overflow.
73+ Only use the macro for small values, prefer _PyTime_FromSeconds(). */
74+ #define _PYTIME_FROMSECONDS (seconds ) \
75+ ((_PyTime_t)(seconds) * (1000 * 1000 * 1000))
7176
7277/* Create a timestamp from a number of nanoseconds. */
7378PyAPI_FUNC (_PyTime_t ) _PyTime_FromNanoseconds (PY_LONG_LONG ns );
Original file line number Diff line number Diff line change @@ -839,7 +839,8 @@ sock_call(PySocketSockObject *s,
839839
840840/* Initialize a new socket object. */
841841
842- static _PyTime_t defaulttimeout = -1 ; /* Default timeout for new sockets */
842+ /* Default timeout for new sockets */
843+ static _PyTime_t defaulttimeout = _PYTIME_FROMSECONDS (-1 );
843844
844845static void
845846init_sockobject (PySocketSockObject * s ,
You can’t perform that action at this time.
0 commit comments