]> granicus.if.org Git - python/commitdiff
Issue #9214: Fix set operations on KeysView and ItemsView.
authorRaymond Hettinger <python@rcn.com>
Sun, 22 Aug 2010 08:01:58 +0000 (08:01 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 22 Aug 2010 08:01:58 +0000 (08:01 +0000)
Lib/_abcoll.py
Misc/NEWS

index a442d7c8a74bbc47f90f1762268d2d8fdfe0b1d2..e9234af3822acb0f332211ddee3cea297a9cfbb6 100644 (file)
@@ -390,6 +390,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
 
@@ -400,6 +404,10 @@ class KeysView(MappingView, Set):
 
 class ItemsView(MappingView, Set):
 
+    @classmethod
+    def _from_iterable(self, it):
+        return set(it)
+
     def __contains__(self, item):
         key, value = item
         try:
index e10f33dd3c4d8625f5992e3bca3de612fe66d23a..d4fb9f2927c482a577039c165418e45b1e775153 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -31,6 +31,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #9214: Set operations on KeysView or ItemsView in the collections
+  module now correctly return a set.  (Patch by Eli Bendersky.)
+
 - Issue #9617: Signals received during a low-level write operation aren't
   ignored by the buffered IO layer anymore.