commit:     3ffdbbe06fab5f3c60d03a77f5a2d08cb94b1869
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Mon Nov 30 23:06:18 2015 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> apache <DOT> org>
CommitDate: Mon Nov 30 23:06:18 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=3ffdbbe0

ebuild: Do not catch unexpected KeyErrors from aux_get().

 bin/ebuild                    |  5 +++--
 pym/portage/dbapi/porttree.py | 20 ++++++++++----------
 pym/portage/exception.py      |  5 ++++-
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/bin/ebuild b/bin/ebuild
index 59fced0..ed1231f 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -1,5 +1,5 @@
 #!/usr/bin/python -bO
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function
@@ -49,6 +49,7 @@ from portage import _shell_quote
 from portage import _unicode_decode
 from portage import _unicode_encode
 from portage.const import VDB_PATH
+from portage.exception import PortageKeyError
 from _emerge.Package import Package
 from _emerge.RootConfig import RootConfig
 
@@ -273,7 +274,7 @@ try:
        metadata = dict(zip(Package.metadata_keys,
                portage.db[portage.settings['EROOT']][mytree].dbapi.aux_get(
                cpv, Package.metadata_keys, myrepo=myrepo)))
-except KeyError:
+except PortageKeyError:
        # aux_get failure, message should have been shown on stderr.
        sys.exit(1)
 

diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index a954de5..23f3169 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2014 Gentoo Foundation
+# Copyright 1998-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import unicode_literals
@@ -23,7 +23,7 @@ from portage.cache import volatile
 from portage.cache.cache_errors import CacheError
 from portage.cache.mappings import Mapping
 from portage.dbapi import dbapi
-from portage.exception import PortageException, \
+from portage.exception import PortageException, PortageKeyError, \
        FileNotFound, InvalidAtom, InvalidData, \
        InvalidDependString, InvalidPackageName
 from portage.localization import _
@@ -435,7 +435,7 @@ class portdbapi(dbapi):
                        writemsg(_("!!! aux_get(): ebuild for " \
                                "'%s' does not exist at:\n") % (cpv,), 
noiselevel=-1)
                        writemsg("!!!            %s\n" % ebuild_path, 
noiselevel=-1)
-                       raise KeyError(cpv)
+                       raise PortageKeyError(cpv)
 
                # Pull pre-generated metadata from the metadata/cache/
                # directory if it exists and is valid, otherwise fall
@@ -481,12 +481,12 @@ class portdbapi(dbapi):
        def aux_get(self, mycpv, mylist, mytree=None, myrepo=None):
                "stub code for returning auxilliary db information, such as 
SLOT, DEPEND, etc."
                'input: "sys-apps/foo-1.0",["SLOT","DEPEND","HOMEPAGE"]'
-               'return: ["0",">=sys-libs/bar-1.0","http://www.foo.com";] or 
raise KeyError if error'
+               'return: ["0",">=sys-libs/bar-1.0","http://www.foo.com";] or 
raise PortageKeyError if error'
                cache_me = False
                if myrepo is not None:
                        mytree = self.treemap.get(myrepo)
                        if mytree is None:
-                               raise KeyError(myrepo)
+                               raise PortageKeyError(myrepo)
 
                if mytree is not None and len(self.porttrees) == 1 \
                        and mytree == self.porttrees[0]:
@@ -507,22 +507,22 @@ class portdbapi(dbapi):
                try:
                        cat, pkg = mycpv.split("/", 1)
                except ValueError:
-                       # Missing slash. Can't find ebuild so raise KeyError.
-                       raise KeyError(mycpv)
+                       # Missing slash. Can't find ebuild so raise 
PortageKeyError.
+                       raise PortageKeyError(mycpv)
 
                myebuild, mylocation = self.findname2(mycpv, mytree)
 
                if not myebuild:
                        writemsg("!!! aux_get(): %s\n" % \
                                _("ebuild not found for '%s'") % mycpv, 
noiselevel=1)
-                       raise KeyError(mycpv)
+                       raise PortageKeyError(mycpv)
 
                mydata, ebuild_hash = self._pull_valid_cache(mycpv, myebuild, 
mylocation)
                doregen = mydata is None
 
                if doregen:
                        if myebuild in self._broken_ebuilds:
-                               raise KeyError(mycpv)
+                               raise PortageKeyError(mycpv)
 
                        proc = EbuildMetadataPhase(cpv=mycpv,
                                ebuild_hash=ebuild_hash, portdb=self,
@@ -534,7 +534,7 @@ class portdbapi(dbapi):
 
                        if proc.returncode != os.EX_OK:
                                self._broken_ebuilds.add(myebuild)
-                               raise KeyError(mycpv)
+                               raise PortageKeyError(mycpv)
 
                        mydata = proc.metadata
 

diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index 857a727..263cdf0 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2014 Gentoo Foundation
+# Copyright 1998-2015 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 import signal
@@ -42,6 +42,9 @@ class PortageException(Exception):
                        else:
                                return repr(self.value)
 
+class PortageKeyError(KeyError, PortageException):
+       __doc__ = KeyError.__doc__
+
 class CorruptionError(PortageException):
        """Corruption indication"""
 

Reply via email to