diff options
author | Guido van Rossum <guido@python.org> | 2002-08-21 03:20:44 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-08-21 03:20:44 +0000 |
commit | 9f87293bf533eb3ac7f770b3bbe1fdf82e7118fb (patch) | |
tree | f115459370c9619c1119d53980aae256bd9a1b9c /Lib/socket.py | |
parent | 26588222b37bf65238eb2d43e2c635213636f3e3 (diff) | |
download | cpython-git-9f87293bf533eb3ac7f770b3bbe1fdf82e7118fb.tar.gz |
Ouch. The test suite *really* needs work!!!!! There were several
superficial errors and one deep one that aren't currently caught. I'm
headed for bed after this checkin.
- Fixed several typos introduced by Raymond Hettinger (through
cut-n-paste from my template): it's _as_temporarily_immutable, not
_as_temporary_immutable, and moreover when the element is added, we
should use _as_immutable.
- Made the seq argument to ImmutableSet.__init__ optional, so we can
write ImmutableSet() to create an immutable empty set.
- Rename the seq argument to Set and ImmutableSet to iterable.
- Add a Set.__hash__ method that raises a TypeError. We inherit a
default __hash__ implementation from object, and we don't want that.
We can then catch this in update(), so that
e.g. s.update([Set([1])]) will transform the Set([1]) to
ImmutableSet([1]).
- Added the dance to catch TypeError and try _as_immutable in the
constructors too (by calling _update()). This is needed so that
Set([Set([1])]) is correctly interpreted as
Set([ImmutableSet([1])]). (I was puzzled by a side effect of this
and the inherited __hash__ when comparing two sets of sets while
testing different powerset implementations: the Set element passed
to a Set constructor wasn't transformed to an ImmutableSet, and then
the dictionary didn't believe the Set found in one dict it was the
same as ImmutableSet in the other, because the hashes were
different.)
- Refactored Set.update() and both __init__() methods; moved the body
of update() into BaseSet as _update(), and call this from __init__()
and update().
- Changed the NotImplementedError in BaseSet.__init__ to TypeError,
both for consistency with basestring() and because we have to use
TypeError when denying Set.__hash__. Together those provide
sufficient evidence that an unimplemented method needs to raise
TypeError.
Diffstat (limited to 'Lib/socket.py')
0 files changed, 0 insertions, 0 deletions