Kaydet (Commit) 50e92235 authored tarafından Guido van Rossum's avatar Guido van Rossum

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.)
üst 8bb90a59
...@@ -102,6 +102,11 @@ class BaseSet(object): ...@@ -102,6 +102,11 @@ class BaseSet(object):
""" """
return self._data.iterkeys() 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 # Equality comparisons using the underlying dicts
def __eq__(self, other): def __eq__(self, other):
......
...@@ -78,6 +78,10 @@ Extension modules ...@@ -78,6 +78,10 @@ Extension modules
Library Library
------- -------
- The sets module now raises TypeError in __cmp__, to clarify that
sets are not intended to be three-way-compared; the comparison
operators are overloaded as subset/superset tests.
- Bastion.py and rexec.py are disabled. These modules are not safe in - Bastion.py and rexec.py are disabled. These modules are not safe in
Python 2.2. or 2.3. Python 2.2. or 2.3.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment