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

Guido van Rossum guido@cnri.reston.va.us
Mon, 28 Feb 2000 10:01:49 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Objects
In directory eric:/projects/python/develop/guido/src/Objects

Modified Files:
	abstract.c 
Log Message:
Patch by Mozhe Zadka, for __contains__ (overloading 'in').  This
patches PySequence_Contains() to check for a valid sq_contains field.
More to follow.


Index: abstract.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/abstract.c,v
retrieving revision 2.30
retrieving revision 2.31
diff -C2 -r2.30 -r2.31
*** abstract.c	2000/02/23 22:21:50	2.30
--- abstract.c	2000/02/28 15:01:46	2.31
***************
*** 1140,1144 ****
  		return 0;
  	}
! 
  	sq = w->ob_type->tp_as_sequence;
  	if (sq == NULL || sq->sq_item == NULL) {
--- 1140,1151 ----
  		return 0;
  	}
! 	if(PyType_HasFeature(w->ob_type, Py_TPFLAGS_HAVE_SEQUENCE_IN)) {
! 		sq = w->ob_type->tp_as_sequence;
! 	        if(sq != NULL && sq->sq_contains != NULL)
! 			return (*sq->sq_contains)(w, v);
! 	}
! 	
! 	/* If there is no better way to check whether an item is is contained,
! 	   do it the hard way */
  	sq = w->ob_type->tp_as_sequence;
  	if (sq == NULL || sq->sq_item == NULL) {