[issue3829] Tuple comparison masking exception
Daniel Stutzbach
report at bugs.python.org
Mon Mar 30 00:23:37 CEST 2009
Daniel Stutzbach <daniel at stutzbachenterprises.com> added the comment:
I don't think the compare is actually masking an exception.
The set type defines a tp_richcompare routine that gets called when
comparing them as members of a tuple, but the set type also defines a
tp_compare routine that does nothing but raise an exception.
Another side effect is that sets are comparable using < etc., but not
with cmp():
>>> s0 = frozenset(['testing 0'])
>>> s1 = frozenset(['testing 1'])
>>> s0 < s1
False
>>> cmp(s0, s1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: cannot compare sets using cmp()
cmp() is gone in 3.0.1 so I've removed Python 3.0 from the versions.
I'm not sure why tp_compare and tp_richcompare work differently. Maybe
Raymond could shed some light?
----------
nosy: +rhettinger, stutzbach
versions: +Python 2.7 -Python 3.0
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3829>
_______________________________________
More information about the Python-bugs-list
mailing list