Handle potential KeyErrors that may be raised from get_eclass_data(), and
authorZac Medico <zmedico@gentoo.org>
Thu, 25 Dec 2008 05:04:53 +0000 (05:04 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 25 Dec 2008 05:04:53 +0000 (05:04 -0000)
remove unnecessary print statements inside get_eclass_data(). (trunk r12329)

svn path=/main/branches/2.1.6/; revision=12335

pym/portage/cache/metadata.py
pym/portage/cache/util.py
pym/portage/eclass_cache.py

index 86717e6c528dc576da88d1b4cf2498ccc5d3495a..b602f62bc8cc7682fc2636630a53f472ffbf4e9e 100644 (file)
@@ -4,7 +4,7 @@
 # $Id$
 
 import os, re, stat, types
-from portage.cache import flat_hash
+from portage.cache import cache_errors, flat_hash
 import portage.eclass_cache 
 from portage.cache.template import reconstruct_eclasses
 from portage.cache.mappings import ProtectedDict
@@ -55,7 +55,12 @@ class database(flat_hash.database):
 
                if "_eclasses_" not in d:
                        if "INHERITED" in d:
-                               d["_eclasses_"] = self.ec.get_eclass_data(d["INHERITED"].split(), from_master_only=True)
+                               try:
+                                       d["_eclasses_"] = self.ec.get_eclass_data(
+                                               d["INHERITED"].split(), from_master_only=True)
+                               except KeyError, e:
+                                       # INHERITED contains a non-existent eclass.
+                                       raise cache_errors.CacheCorruption(cpv, e)
                                del d["INHERITED"]
                        else:
                                d["_eclasses_"] = {}
index 26bc5f9e0709c3a97cbf35fabd351f8503fdd27a..7d81f2d05dacca942119689e26f8189210cdc045 100644 (file)
@@ -90,8 +90,14 @@ def mirror_cache(valid_nodes_iterable, src_cache, trg_cache, eclass_cache=None,
 
                                # Even if _eclasses_ already exists, replace it with data from
                                # eclass_cache, in order to insert local eclass paths.
-                               eclasses = eclass_cache.get_eclass_data(inherited,
-                                       from_master_only=True)
+                               try:
+                                       eclasses = eclass_cache.get_eclass_data(inherited,
+                                               from_master_only=True)
+                               except KeyError:
+                                       # INHERITED contains a non-existent eclass.
+                                       noise.eclass_stale(x)
+                                       continue
+
                                if eclasses is None:
                                        noise.eclass_stale(x)
                                        continue
index 93c956f8a3e410554aa151f7f5be592566d4bb27..670e9fb245201165d2ddb89a7ab1cf0274f9701b 100644 (file)
@@ -99,12 +99,7 @@ class cache(object):
        def get_eclass_data(self, inherits, from_master_only=False):
                ec_dict = {}
                for x in inherits:
-                       try:
-                               ec_dict[x] = self.eclasses[x]
-                       except KeyError:
-                               print "ec=",ec_dict
-                               print "inherits=",inherits
-                               raise
+                       ec_dict[x] = self.eclasses[x]
                        if from_master_only and \
                                self._eclass_locations[x] != self._master_eclass_root:
                                return None