summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-12-25 04:22:46 +0000
committerZac Medico <zmedico@gentoo.org>2008-12-25 04:22:46 +0000
commit094e4d97d67f8e39aa17ea39bad04daa2cd26350 (patch)
tree33d8fcf9949b6b8874bfd1161de4d7c7b318f9fe
parentff3b62faa19303bfdc36c961e3e9c2fc6f74074f (diff)
downloadportage-094e4d97d67f8e39aa17ea39bad04daa2cd26350.tar.gz
portage-094e4d97d67f8e39aa17ea39bad04daa2cd26350.tar.bz2
portage-094e4d97d67f8e39aa17ea39bad04daa2cd26350.zip
Handle potential KeyErrors that may be raised from get_eclass_data(), and
remove unnecessary print statements inside get_eclass_data(). svn path=/main/trunk/; revision=12329
-rw-r--r--pym/portage/cache/metadata.py9
-rw-r--r--pym/portage/cache/util.py10
-rw-r--r--pym/portage/eclass_cache.py7
3 files changed, 16 insertions, 10 deletions
diff --git a/pym/portage/cache/metadata.py b/pym/portage/cache/metadata.py
index 86717e6c5..b602f62bc 100644
--- a/pym/portage/cache/metadata.py
+++ b/pym/portage/cache/metadata.py
@@ -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_"] = {}
diff --git a/pym/portage/cache/util.py b/pym/portage/cache/util.py
index 26bc5f9e0..7d81f2d05 100644
--- a/pym/portage/cache/util.py
+++ b/pym/portage/cache/util.py
@@ -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
diff --git a/pym/portage/eclass_cache.py b/pym/portage/eclass_cache.py
index 93c956f8a..670e9fb24 100644
--- a/pym/portage/eclass_cache.py
+++ b/pym/portage/eclass_cache.py
@@ -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