summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-03-30 23:55:31 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-03-30 23:55:31 (GMT)
commit074c3e62d155349a69442f43e81a73883f222ea9 (patch)
tree50a773b1a903857944554bb06372decdf5addb3d /Python/ceval.c
parentaaf0ab26ed4fd02da874a9d2eee68b7c64e8377d (diff)
downloadcpython-074c3e62d155349a69442f43e81a73883f222ea9.zip
cpython-074c3e62d155349a69442f43e81a73883f222ea9.tar.gz
cpython-074c3e62d155349a69442f43e81a73883f222ea9.tar.bz2
Two fixes for extended call syntax:
If a non-tuple sequence is passed as the *arg, convert it to a tuple before checking its length. If named keyword arguments are used in combination with **kwargs, make a copy of kwargs before inserting the new keys.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index d7171c8..6b3b257 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1635,7 +1635,18 @@ eval_code2(co, globals, locals,
x = NULL;
break;
}
- nstar = PySequence_Length(stararg);
+ /* Convert abstract sequence to concrete tuple */
+ if (!PyTuple_Check(stararg)) {
+ PyObject *t = NULL;
+ t = PySequence_Tuple(stararg);
+ if (t == NULL) {
+ x = NULL;
+ break;
+ }
+ Py_DECREF(stararg);
+ stararg = t;
+ }
+ nstar = PyTuple_GET_SIZE(stararg);
if (nstar < 0) {
x = NULL;
break;
@@ -1649,6 +1660,15 @@ eval_code2(co, globals, locals,
break;
}
}
+ else {
+ PyObject *d = PyDict_Copy(kwdict);
+ if (d == NULL) {
+ x = NULL;
+ break;
+ }
+ Py_DECREF(kwdict);
+ kwdict = d;
+ }
err = 0;
while (--nk >= 0) {
PyObject *value = POP();
@@ -1678,18 +1698,7 @@ eval_code2(co, globals, locals,
break;
}
if (stararg) {
- PyObject *t = NULL;
int i;
- if (!PyTuple_Check(stararg)) {
- /* must be sequence to pass earlier test */
- t = PySequence_Tuple(stararg);
- if (t == NULL) {
- x = NULL;
- break;
- }
- Py_DECREF(stararg);
- stararg = t;
- }
for (i = 0; i < nstar; i++) {
PyObject *a = PyTuple_GET_ITEM(stararg, i);
Py_INCREF(a);