[Python-checkins] CVS: python/dist/src/Objects abstract.c,2.28,2.29

Andrew M. Kuchling akuchlin@CNRI.Reston.VA.US
Mon, 14 Feb 2000 17:22:08 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Objects
In directory amarok:/home/akuchlin/src/Python-1.5/Objects

Modified Files:
	abstract.c 
Log Message:
Make multiplying a sequence by a long integer (5L * 'b') legal


Index: abstract.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/abstract.c,v
retrieving revision 2.28
retrieving revision 2.29
diff -C2 -r2.28 -r2.29
*** abstract.c	1999/10/12 19:54:47	2.28
--- abstract.c	2000/02/14 22:22:04	2.29
***************
*** 385,392 ****
  	m = tp->tp_as_sequence;
  	if (m && m->sq_repeat) {
! 		if (!PyInt_Check(w))
  			return type_error(
  				"can't multiply sequence with non-int");
! 		return (*m->sq_repeat)(v, (int)PyInt_AsLong(w));
  	}
  	return type_error("bad operand type(s) for *");
--- 385,403 ----
  	m = tp->tp_as_sequence;
  	if (m && m->sq_repeat) {
! 		long mul_value;
! 
! 		if (PyInt_Check(w)) {
! 			mul_value = PyInt_AsLong(w);
! 		}
! 		else if (PyLong_Check(w)) {
! 			mul_value = PyLong_AsLong(w);
! 			if (PyErr_Occurred())
!                                 return NULL; 
! 		}
! 		else {
  			return type_error(
  				"can't multiply sequence with non-int");
! 		}
! 		return (*m->sq_repeat)(v, (int)mul_value);
  	}
  	return type_error("bad operand type(s) for *");