From 60ab92d85a73db9b72c8155ea61da1d91623699c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 25 Dec 2008 05:04:53 +0000 Subject: [PATCH] Handle potential KeyErrors that may be raised from get_eclass_data(), and remove unnecessary print statements inside get_eclass_data(). (trunk r12329) svn path=/main/branches/2.1.6/; revision=12335 --- pym/portage/cache/metadata.py | 9 +++++++-- pym/portage/cache/util.py | 10 ++++++++-- pym/portage/eclass_cache.py | 7 +------ 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 -- 2.26.2