[Python-checkins] cpython: Minor code cleanup for PyArg_UnpackTuple.
raymond.hettinger
python-checkins at python.org
Sat Mar 26 06:04:09 EDT 2016
https://hg.python.org/cpython/rev/fdbd238fc9e1
changeset: 100759:fdbd238fc9e1
user: Raymond Hettinger <python at rcn.com>
date: Sat Mar 26 03:02:48 2016 -0700
summary:
Minor code cleanup for PyArg_UnpackTuple.
files:
Python/getargs.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/Python/getargs.c b/Python/getargs.c
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -1771,16 +1771,9 @@
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 @@
"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 @@
"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);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list