Minor code cleanup for PyArg_UnpackTuple.
This commit is contained in:
parent
53b0a41d31
commit
942302371c
|
@ -1771,16 +1771,9 @@ PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t m
|
||||||
PyObject **o;
|
PyObject **o;
|
||||||
va_list vargs;
|
va_list vargs;
|
||||||
|
|
||||||
#ifdef HAVE_STDARG_PROTOTYPES
|
|
||||||
va_start(vargs, max);
|
|
||||||
#else
|
|
||||||
va_start(vargs);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
assert(min >= 0);
|
assert(min >= 0);
|
||||||
assert(min <= max);
|
assert(min <= max);
|
||||||
if (!PyTuple_Check(args)) {
|
if (!PyTuple_Check(args)) {
|
||||||
va_end(vargs);
|
|
||||||
PyErr_SetString(PyExc_SystemError,
|
PyErr_SetString(PyExc_SystemError,
|
||||||
"PyArg_UnpackTuple() argument list is not a tuple");
|
"PyArg_UnpackTuple() argument list is not a tuple");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1798,9 +1791,10 @@ PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t m
|
||||||
"unpacked tuple should have %s%zd elements,"
|
"unpacked tuple should have %s%zd elements,"
|
||||||
" but has %zd",
|
" but has %zd",
|
||||||
(min == max ? "" : "at least "), min, l);
|
(min == max ? "" : "at least "), min, l);
|
||||||
va_end(vargs);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (l == 0)
|
||||||
|
return 1;
|
||||||
if (l > max) {
|
if (l > max) {
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
PyErr_Format(
|
PyErr_Format(
|
||||||
|
@ -1813,9 +1807,14 @@ PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t m
|
||||||
"unpacked tuple should have %s%zd elements,"
|
"unpacked tuple should have %s%zd elements,"
|
||||||
" but has %zd",
|
" but has %zd",
|
||||||
(min == max ? "" : "at most "), max, l);
|
(min == max ? "" : "at most "), max, l);
|
||||||
va_end(vargs);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_STDARG_PROTOTYPES
|
||||||
|
va_start(vargs, max);
|
||||||
|
#else
|
||||||
|
va_start(vargs);
|
||||||
|
#endif
|
||||||
for (i = 0; i < l; i++) {
|
for (i = 0; i < l; i++) {
|
||||||
o = va_arg(vargs, PyObject **);
|
o = va_arg(vargs, PyObject **);
|
||||||
*o = PyTuple_GET_ITEM(args, i);
|
*o = PyTuple_GET_ITEM(args, i);
|
||||||
|
|
Loading…
Reference in New Issue