mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Issue #9214: Fix set operations on KeysView and ItemsView.
This commit is contained in:
parent
a52bae7521
commit
9117c75148
3 changed files with 37 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue