Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c7a2270

Browse files
committed
* selectmodule.c (select_select): timeout argument may be None with same
meaning as no 4th argument
1 parent 82d410e commit c7a2270

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

Modules/selectmodule.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ select_select(self, args)
114114
{
115115
object *fd2obj[FD_SETSIZE];
116116
object *ifdlist, *ofdlist, *efdlist;
117-
object *ret;
117+
object *ret, *tout;
118118
fd_set ifdset, ofdset, efdset;
119119
double timeout;
120120
struct timeval tv, *tvp;
@@ -124,12 +124,18 @@ select_select(self, args)
124124

125125

126126
/* Get args. Looks funny because of optional timeout argument */
127-
if ( getargs(args, "(OOOd)", &ifdlist, &ofdlist, &efdlist, &timeout) ) {
127+
if ( getargs(args, "(OOOO)", &ifdlist, &ofdlist, &efdlist, &tout) ) {
128128
seconds = (int)timeout;
129-
timeout = timeout - (double)seconds;
130-
tv.tv_sec = seconds;
131-
tv.tv_usec = (int)(timeout*1000000.0);
132-
tvp = &tv;
129+
if (tout == None)
130+
tvp = (struct timeval *)0;
131+
else {
132+
if (!getargs(tout, "%d;timeout must be float or None", &timeout))
133+
return NULL;
134+
timeout = timeout - (double)seconds;
135+
tv.tv_sec = seconds;
136+
tv.tv_usec = (int)(timeout*1000000.0);
137+
tvp = &tv;
138+
}
133139
} else {
134140
/* Doesn't have 4 args, that means no timeout */
135141
err_clear();

0 commit comments

Comments
 (0)