Fix classes that implement __iter__() to copy it to their keys() method
authorZac Medico <zmedico@gentoo.org>
Thu, 19 Feb 2009 03:53:21 +0000 (03:53 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 19 Feb 2009 03:53:21 +0000 (03:53 -0000)
when running under >=python-3.0.

svn path=/main/trunk/; revision=12632

pym/portage/cache/mappings.py
pym/portage/cache/sql_template.py

index a767e1bc5c80cef2e33b6aa0da35d0469ab32a8b..5fe836daad115c468b266ef2247c25fb98ae2bee 100644 (file)
@@ -165,6 +165,9 @@ class UserDict(MutableMapping):
        def clear(self):
                self.data.clear()
 
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+
 class ProtectedDict(MutableMapping):
        """
        given an initial dict, this wraps that dict storing changes in a secondary dict, protecting
@@ -218,6 +221,9 @@ class ProtectedDict(MutableMapping):
                        DeprecationWarning)
                return key in self
 
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+
 class LazyLoad(Mapping):
        """
        Lazy loading of values for a dict
@@ -259,6 +265,9 @@ class LazyLoad(Mapping):
                        self.pull = None
                return key in self.d
 
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+
 _slot_dict_classes = weakref.WeakValueDictionary()
 
 def slot_dict_class(keys, prefix="_val_"):
index e5903cd67382ace9be3e2b6167d0a5f3ef3c5c6c..47bef9124957dec236756fbe3d28fa62af200259 100644 (file)
@@ -280,3 +280,4 @@ class SQLDatabase(template.database):
 
        if sys.hexversion >= 0x3000000:
                items = iteritems
+               keys = __iter__