Skip to content

Commit 5e28a99

Browse files
author
nnorwitz
committed
SF patch #577031, remove PyArg_Parse() since it's deprecated
git-svn-id: http://svn.python.org/projects/python/trunk@27799 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent b3c788e commit 5e28a99

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

Modules/selectmodule.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,17 @@ select_select(PyObject *self, PyObject *args)
208208

209209
if (tout == Py_None)
210210
tvp = (struct timeval *)0;
211-
else if (!PyArg_Parse(tout, "d", &timeout)) {
211+
else if (!PyNumber_Check(tout)) {
212212
PyErr_SetString(PyExc_TypeError,
213213
"timeout must be a float or None");
214214
return NULL;
215215
}
216216
else {
217+
tout = PyNumber_Float(tout);
218+
if (!tout)
219+
return NULL;
220+
timeout = PyFloat_AS_DOUBLE(tout);
221+
Py_DECREF(tout);
217222
if (timeout > (double)LONG_MAX) {
218223
PyErr_SetString(PyExc_OverflowError,
219224
"timeout period too long");
@@ -450,11 +455,18 @@ poll_poll(pollObject *self, PyObject *args)
450455
/* Check values for timeout */
451456
if (tout == NULL || tout == Py_None)
452457
timeout = -1;
453-
else if (!PyArg_Parse(tout, "i", &timeout)) {
458+
else if (!PyNumber_Check(tout)) {
454459
PyErr_SetString(PyExc_TypeError,
455460
"timeout must be an integer or None");
456461
return NULL;
457462
}
463+
else {
464+
tout = PyNumber_Int(tout);
465+
if (!tout)
466+
return NULL;
467+
timeout = PyInt_AS_LONG(tout);
468+
Py_DECREF(tout);
469+
}
458470

459471
/* Ensure the ufd array is up to date */
460472
if (!self->ufd_uptodate)

0 commit comments

Comments
 (0)