[Python-checkins] CVS: python/dist/src/Objects listobject.c,2.65,2.66

Guido van Rossum guido@cnri.reston.va.us
Mon, 13 Mar 2000 10:42:02 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Objects
In directory eric:/home/guido/hp/mal/py-patched/Objects

Modified Files:
	listobject.c 
Log Message:
Added Christian Tismer's patch to allow list.append(a,b,c) back --
with a twist: you have to define NO_STRICT_LIST_APPEND manually
to enable multi-arg append().


Index: listobject.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/listobject.c,v
retrieving revision 2.65
retrieving revision 2.66
diff -C2 -r2.65 -r2.66
*** listobject.c	2000/02/24 21:48:29	2.65
--- listobject.c	2000/03/13 15:41:59	2.66
***************
*** 563,566 ****
--- 563,580 ----
  }
  
+ /* Define NO_STRICT_LIST_APPEND to enable multi-argument append() */
+ 
+ #ifndef NO_STRICT_LIST_APPEND
+ #define PyArg_ParseTuple_Compat1 PyArg_ParseTuple
+ #else
+ #define PyArg_ParseTuple_Compat1(args, format, ret) \
+ ( \
+ 	PyTuple_GET_SIZE(args) > 1 ? (*ret = args, 1) : \
+ 	PyTuple_GET_SIZE(args) == 1 ? (*ret = PyTuple_GET_ITEM(args, 0), 1) : \
+ 	PyArg_ParseTuple(args, format, ret) \
+ )
+ #endif
+ 
+ 
  static PyObject *
  listappend(self, args)
***************
*** 569,573 ****
  {
  	PyObject *v;
! 	if (!PyArg_ParseTuple(args, "O:append", &v))
  		return NULL;
  	return ins(self, (int) self->ob_size, v);
--- 583,587 ----
  {
  	PyObject *v;
! 	if (!PyArg_ParseTuple_Compat1(args, "O:append", &v))
  		return NULL;
  	return ins(self, (int) self->ob_size, v);
***************
*** 1327,1331 ****
  	PyObject *v;
  
! 	if (!PyArg_ParseTuple(args, "O:index", &v))
  		return NULL;
  	for (i = 0; i < self->ob_size; i++) {
--- 1341,1345 ----
  	PyObject *v;
  
! 	if (!PyArg_ParseTuple_Compat1(args, "O:index", &v))
  		return NULL;
  	for (i = 0; i < self->ob_size; i++) {
***************
*** 1348,1352 ****
  	PyObject *v;
  
! 	if (!PyArg_ParseTuple(args, "O:count", &v))
  		return NULL;
  	for (i = 0; i < self->ob_size; i++) {
--- 1362,1366 ----
  	PyObject *v;
  
! 	if (!PyArg_ParseTuple_Compat1(args, "O:count", &v))
  		return NULL;
  	for (i = 0; i < self->ob_size; i++) {
***************
*** 1367,1371 ****
  	PyObject *v;
  
! 	if (!PyArg_ParseTuple(args, "O:remove", &v))
  		return NULL;
  	for (i = 0; i < self->ob_size; i++) {
--- 1381,1385 ----
  	PyObject *v;
  
! 	if (!PyArg_ParseTuple_Compat1(args, "O:remove", &v))
  		return NULL;
  	for (i = 0; i < self->ob_size; i++) {