Fix an issue with incomplete deepcopy of _LazyItem instances inside
authorZac Medico <zmedico@gentoo.org>
Sat, 7 Mar 2009 21:34:50 +0000 (21:34 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 7 Mar 2009 21:34:50 +0000 (21:34 -0000)
LazyItemsDict.__deepcopy__(). Thanks to Arfrever for reporting.

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

pym/portage/util.py

index c84f351beb2ecf00c14870a5e54beb6b380b86e6..c55da036604623db633255478d2676deb32ae5f6 100644 (file)
@@ -1170,17 +1170,12 @@ class LazyItemsDict(dict):
                memo[id(self)] = result
                for k in self:
                        k_copy = deepcopy(k, memo)
-                       if k in self.lazy_items:
+                       if k in list(self.lazy_items):
                                lazy_item = self.lazy_items[k]
-                               try:
-                                       result.lazy_items[k_copy] = deepcopy(lazy_item, memo)
-                               except TypeError:
-                                       # If deepcopy fails for a lazy singleton, try to
-                                       # evaluate the singleton and deepcopy the result.
-                                       if not lazy_item.singleton:
-                                               raise
+                               if lazy_item.singleton:
                                        dict.__setitem__(result, k_copy, deepcopy(self[k], memo))
                                else:
+                                       result.lazy_items[k_copy] = deepcopy(lazy_item, memo)
                                        dict.__setitem__(result, k_copy, None)
                        else:
                                dict.__setitem__(result, k_copy, deepcopy(self[k], memo))