[Python-bugs-list] [ python-Bugs-439104 ] Tuple richcompares has code-typo

noreply@sourceforge.net noreply@sourceforge.net
Fri, 06 Jul 2001 09:17:19 -0700


Bugs item #439104, was opened at 2001-07-06 09:17
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=439104&group_id=5470

Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Tuple richcompares has code-typo

Initial Comment:
In the tupleobject.c source, there is a switch
statement to handle rich compares.  In the case
of Py_LE, the *wrong* variable is used in the
logical test.  It uses 'ws <= ws' and it should
be 'vs <= ws'.              <jrush@taupro.com>

	if (i >= vt->ob_size || i >= wt->ob_size) {
		/* No more items to compare -- compare sizes */
		int vs = vt->ob_size;
		int ws = wt->ob_size;
		int cmp;
		PyObject *res;
		switch (op) {
		case Py_LT: cmp = vs <  ws; break;
        ------>	case Py_LE: cmp = ws <= ws; break;
		case Py_EQ: cmp = vs == ws; break;
		case Py_NE: cmp = vs != ws; break;
		case Py_GT: cmp = vs >  ws; break;
		case Py_GE: cmp = vs >= ws; break;
		default: return NULL; /* cannot happen */
		}
		if (cmp)
			res = Py_True;
		else
			res = Py_False;
		Py_INCREF(res);
		return res;
	}

(This is in Python 2.1 stable release version)


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=439104&group_id=5470