summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-01-14 18:29:20 (GMT)
committerGuido van Rossum <guido@python.org>1992-01-14 18:29:20 (GMT)
commit6a3f9a841a640ecf7d76078eb9e0c58f33907eb7 (patch)
tree83caf10b832f4ea77929c8257d8b24b09a560ec2 /Python/ceval.c
parent31104f462417ac03ae67b4824a02f085cc8fa100 (diff)
downloadcpython-6a3f9a841a640ecf7d76078eb9e0c58f33907eb7.zip
cpython-6a3f9a841a640ecf7d76078eb9e0c58f33907eb7.tar.gz
cpython-6a3f9a841a640ecf7d76078eb9e0c58f33907eb7.tar.bz2
Added UNPACK_VARARG code.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 129d743..cc2f034 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -639,6 +639,42 @@ eval_code(co, globals, locals, arg)
err_setstr(NameError, getstringvalue(w));
break;
+ case UNPACK_VARARG:
+ if (EMPTY()) {
+ err_setstr(TypeError,
+ "no argument list");
+ why = WHY_EXCEPTION;
+ break;
+ }
+ v = POP();
+ if (!is_tupleobject(v)) {
+ err_setstr(TypeError,
+ "bad argument list");
+ why = WHY_EXCEPTION;
+ }
+ else if (gettuplesize(v) < oparg) {
+ err_setstr(TypeError,
+ "not enough arguments");
+ why = WHY_EXCEPTION;
+ }
+ else if (oparg == 0) {
+ PUSH(v);
+ break;
+ }
+ else {
+ x = gettupleslice(v, oparg, gettuplesize(v));
+ if (x != NULL) {
+ PUSH(x);
+ for (; --oparg >= 0; ) {
+ w = gettupleitem(v, oparg);
+ INCREF(w);
+ PUSH(w);
+ }
+ }
+ }
+ DECREF(v);
+ break;
+
case UNPACK_ARG:
/* Implement various compatibility hacks:
(a) f(a,b,...) should accept f((1,2,...))