diff options
author | Raymond Hettinger <python@rcn.com> | 2016-03-26 10:02:48 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2016-03-26 10:02:48 (GMT) |
commit | 942302371c1e46fdf486a5be0e036f7232a2fba1 (patch) | |
tree | ad14ca283e9499ae7600ef7f1589ca577568e81f | |
parent | 53b0a41d3103ab84f3ef9a1532bf95cff8819636 (diff) | |
download | cpython-942302371c1e46fdf486a5be0e036f7232a2fba1.zip cpython-942302371c1e46fdf486a5be0e036f7232a2fba1.tar.gz cpython-942302371c1e46fdf486a5be0e036f7232a2fba1.tar.bz2 |
Minor code cleanup for PyArg_UnpackTuple.
-rw-r--r-- | Python/getargs.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Python/getargs.c b/Python/getargs.c index 66a0c00..05ec27b 100644 --- a/Python/getargs.c +++ b/Python/getargs.c @@ -1771,16 +1771,9 @@ PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t m PyObject **o; va_list vargs; -#ifdef HAVE_STDARG_PROTOTYPES - va_start(vargs, max); -#else - va_start(vargs); -#endif - assert(min >= 0); assert(min <= max); if (!PyTuple_Check(args)) { - va_end(vargs); PyErr_SetString(PyExc_SystemError, "PyArg_UnpackTuple() argument list is not a tuple"); 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," " but has %zd", (min == max ? "" : "at least "), min, l); - va_end(vargs); return 0; } + if (l == 0) + return 1; if (l > max) { if (name != NULL) 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," " but has %zd", (min == max ? "" : "at most "), max, l); - va_end(vargs); return 0; } + +#ifdef HAVE_STDARG_PROTOTYPES + va_start(vargs, max); +#else + va_start(vargs); +#endif for (i = 0; i < l; i++) { o = va_arg(vargs, PyObject **); *o = PyTuple_GET_ITEM(args, i); |