@@ -84,7 +84,6 @@ static int slice_index Py_PROTO((PyObject *, int *));
8484static PyObject * apply_slice Py_PROTO ((PyObject * , PyObject * , PyObject * ) );
8585static int assign_slice Py_PROTO ((PyObject * , PyObject * ,
8686 PyObject * , PyObject * ) );
87- static int cmp_member Py_PROTO ((PyObject * , PyObject * ) );
8887static PyObject * cmp_outcome Py_PROTO ((int , PyObject * , PyObject * ));
8988static int import_from Py_PROTO ((PyObject * , PyObject * , PyObject * ) );
9089static PyObject * build_class Py_PROTO ((PyObject * , PyObject * , PyObject * ) );
@@ -2496,7 +2495,7 @@ loop_subscript(v, w)
24962495{
24972496 PySequenceMethods * sq = v -> ob_type -> tp_as_sequence ;
24982497 int i ;
2499- if (sq == NULL ) {
2498+ if (sq == NULL || sq -> sq_item == NULL ) {
25002499 PyErr_SetString (PyExc_TypeError , "loop over non-sequence" );
25012500 return NULL ;
25022501 }
@@ -2559,56 +2558,6 @@ assign_slice(u, v, w, x) /* u[v:w] = x */
25592558 return PySequence_SetSlice (u , ilow , ihigh , x );
25602559}
25612560
2562- static int
2563- cmp_member (v , w )
2564- PyObject * v , * w ;
2565- {
2566- int i , cmp ;
2567- PyObject * x ;
2568- PySequenceMethods * sq ;
2569- /* Special case for char in string */
2570- if (PyString_Check (w )) {
2571- register char * s , * end ;
2572- register char c ;
2573- if (!PyString_Check (v ) || PyString_Size (v ) != 1 ) {
2574- PyErr_SetString (PyExc_TypeError ,
2575- "string member test needs char left operand" );
2576- return -1 ;
2577- }
2578- c = PyString_AsString (v )[0 ];
2579- s = PyString_AsString (w );
2580- end = s + PyString_Size (w );
2581- while (s < end ) {
2582- if (c == * s ++ )
2583- return 1 ;
2584- }
2585- return 0 ;
2586- }
2587- sq = w -> ob_type -> tp_as_sequence ;
2588- if (sq == NULL ) {
2589- PyErr_SetString (PyExc_TypeError ,
2590- "'in' or 'not in' needs sequence right argument" );
2591- return -1 ;
2592- }
2593- for (i = 0 ; ; i ++ ) {
2594- x = (* sq -> sq_item )(w , i );
2595- if (x == NULL ) {
2596- if (PyErr_Occurred () == PyExc_IndexError ) {
2597- PyErr_Clear ();
2598- break ;
2599- }
2600- return -1 ;
2601- }
2602- cmp = PyObject_Compare (v , x );
2603- Py_XDECREF (x );
2604- if (cmp == 0 )
2605- return 1 ;
2606- if (PyErr_Occurred ())
2607- return -1 ;
2608- }
2609- return 0 ;
2610- }
2611-
26122561static PyObject *
26132562cmp_outcome (op , v , w )
26142563 int op ;
@@ -2626,7 +2575,7 @@ cmp_outcome(op, v, w)
26262575 break ;
26272576 case IN :
26282577 case NOT_IN :
2629- res = cmp_member ( v , w );
2578+ res = PySequence_Contains ( w , v );
26302579 if (res < 0 )
26312580 return NULL ;
26322581 if (op == (int ) NOT_IN )
0 commit comments