[Python-bugs-list] [ python-Bugs-439104 ] Tuple richcompares has code-typo
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 06 Jul 2001 10:42:14 -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: 7
Submitted By: Nobody/Anonymous (nobody)
>Assigned to: Tim Peters (tim_one)
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)
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2001-07-06 10:42
Message:
Logged In: YES
user_id=31435
Assigned to me and boosted priority. This is already fixed
in CVS, but there's an isomorphic error in list
richcompares. Both are broken in the 2.1.1 maintenance
branch.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=439104&group_id=5470