New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tuple comparison masking exception #48079
Comments
There's a strange condition where cmp() of tuples of unorderable values If I have these two unorderable values, cmp() raises an expected exception: >>> s0 = frozenset(['testing 0'])
>>> s1 = frozenset(['testing 1'])
>>> cmp(s0, s1)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: cannot compare sets using cmp() Comparing tuples of the values returns -1: >>> cmp((s0,), (s1,))
-1 Py3k does raise a TypeError, but the message is indecipherable: >>> cmp((s0,), (s1,))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: 'tuple' != 'tuple' (The Py3k message for the set comparison is the same as for Python 2.) I believe that this is an error; the exception from the underlying item |
I don't think the compare is actually masking an exception. The set type defines a tp_richcompare routine that gets called when Another side effect is that sets are comparable using < etc., but not >>> 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 |
Daniel, you're basically on the money. No exception is getting masked. The rich comparison operations for sets are defined as subset/superset |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: