mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
Explicitly raise an exception in __cmp__ -- this clarifies that cmp()
is not supported on sets. (Unfortunately, sorting a list of sets may still return random results because it uses < exclusively, but for sets that inly implements a partial ordering. Oh well.)
This commit is contained in:
parent
8bb90a59a6
commit
50e92235e7
2 changed files with 9 additions and 0 deletions
|
@ -102,6 +102,11 @@ class BaseSet(object):
|
|||
"""
|
||||
return self._data.iterkeys()
|
||||
|
||||
# Three-way comparison is not supported
|
||||
|
||||
def __cmp__(self, other):
|
||||
raise TypeError, "can't compare sets using cmp()"
|
||||
|
||||
# Equality comparisons using the underlying dicts
|
||||
|
||||
def __eq__(self, other):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue