Commits

jayd3e committed dfd6359

Fixed iteritems/keys/values in Multidict, UnicodeMultidict, and NestedMultidict.

Comments (0)

Files changed (1)

     ## All the iteration:
     ##
 
-    def keys(self):
-        return [k for k, v in self._items]
-
     def iterkeys(self):
         for k, v in self._items:
             yield k
 
     __iter__ = iterkeys
-
-    def items(self):
-        return list(self._items)
-
+    
     def iteritems(self):
         return iter(self._items)
-
-    def values(self):
-        return [v for k, v in self._items]
-
+    
     def itervalues(self):
         for k, v in self._items:
             yield v
+    
+    if six.PY3:
+        items = iteritems
+        keys = iterkeys
+        values = itervalues
+    else:
+        def keys(self):
+            return list(self.iterkeys())
+
+        def items(self):
+            return list(self.iteritems())
+        
+        def values(self):
+            return list(self.itervalues())
+
 
 class UnicodeMultiDict(DictMixin):
     """
         keys = iterkeys
         values = itervalues
     else:
+        def keys(self):
+            return list(self.iterkeys())
+
         def items(self):
-            return list(_iteritems(self.multi))
-        
-        def keys(self):
-            return list(_iterkeys(self.multi))
+            return list(self.iteritems())
         
         def values(self):
-            return list(_itervalues(self.multi))
+            return list(self.itervalues())
 
 _dummy = object()
 
                 return True
         return False
 
-    def items(self):
-        return list(self.iteritems())
-
     def iteritems(self):
         for d in self.dicts:
             for item in d.iteritems():
                 yield item
 
-    def values(self):
-        return list(self.itervalues())
-
     def itervalues(self):
         for d in self.dicts:
             for value in d.itervalues():
                 yield value
 
-    def keys(self):
-        return list(self.iterkeys())
-
-    def __iter__(self):
+    def iterkeys(self):
         for d in self.dicts:
             for key in d:
                 yield key
 
-    iterkeys = __iter__
-
 class NoVars(object):
     """
     Represents no variables; used when no variables