Issue #9214: Fix set operations on KeysView and ItemsView.

This commit is contained in:
Raymond Hettinger 2010-08-22 07:44:24 +00:00
parent a52bae7521
commit 9117c75148
3 changed files with 37 additions and 1 deletions

View file

@ -393,6 +393,10 @@ class MappingView(Sized):
class KeysView(MappingView, Set):
@classmethod
def _from_iterable(self, it):
return set(it)
def __contains__(self, key):
return key in self._mapping
@ -405,6 +409,10 @@ KeysView.register(dict_keys)
class ItemsView(MappingView, Set):
@classmethod
def _from_iterable(self, it):
return set(it)
def __contains__(self, item):
key, value = item
try: