[Python-checkins] CVS: python/dist/src/Python ceval.c,2.171,2.172
Jeremy Hylton
python-dev@python.org
2000年3月30日 18:55:34 -0500
Update of /projects/cvsroot/python/dist/src/Python
In directory goon.cnri.reston.va.us:/home/jhylton/python/src/Python
Modified Files:
ceval.c
Log Message:
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.
Index: ceval.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Python/ceval.c,v
retrieving revision 2.171
retrieving revision 2.172
diff -C2 -r2.171 -r2.172
*** ceval.c 2000年03月29日 18:36:49 2.171
--- ceval.c 2000年03月30日 23:55:31 2.172
***************
*** 1636,1640 ****
break;
}
! nstar = PySequence_Length(stararg);
if (nstar < 0) {
x = NULL;
--- 1636,1651 ----
break;
}
! /* 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;
***************
*** 1650,1653 ****
--- 1661,1673 ----
}
}
+ else {
+ PyObject *d = PyDict_Copy(kwdict);
+ if (d == NULL) {
+ x = NULL;
+ break;
+ }
+ Py_DECREF(kwdict);
+ kwdict = d;
+ }
err = 0;
while (--nk >= 0) {
***************
*** 1679,1694 ****
}
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);
--- 1699,1703 ----