commit:     34f4f163eaadbccb0e37dbb780278bfacb8e8edb
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 25 08:38:44 2016 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Jan 25 08:39:26 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=34f4f163

Fix KeyError for ACCEPT_KEYWORDS and ARCH (bug 572826)

Use the "get" method to avoid triggering a KeyError when the profile is
invalid.

Fixes: 39d81c514c33 ("[...]config.__getitem__(): Partially drop backward 
compatibility for nonexistent keys.")
X-Gentoo-Bug: 572826
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=572826

 pym/portage/_legacy_globals.py       | 2 +-
 pym/portage/news.py                  | 2 +-
 pym/portage/package/ebuild/config.py | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pym/portage/_legacy_globals.py b/pym/portage/_legacy_globals.py
index bb9691a..f916cc6 100644
--- a/pym/portage/_legacy_globals.py
+++ b/pym/portage/_legacy_globals.py
@@ -56,7 +56,7 @@ def _get_legacy_global(name):
        portage.features = settings.features
        constructed.add('features')
 
-       portage.groups = settings["ACCEPT_KEYWORDS"].split()
+       portage.groups = settings.get("ACCEPT_KEYWORDS", "").split()
        constructed.add('groups')
 
        portage.pkglines = settings.packages

diff --git a/pym/portage/news.py b/pym/portage/news.py
index 54d4dc9..784ba70 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -338,7 +338,7 @@ class DisplayKeywordRestriction(DisplayRestriction):
                self.keyword = keyword
 
        def checkRestriction(self, **kwargs):
-               if kwargs['config']['ARCH'] == self.keyword:
+               if kwargs['config'].get('ARCH', '') == self.keyword:
                        return True
                return False
 

diff --git a/pym/portage/package/ebuild/config.py 
b/pym/portage/package/ebuild/config.py
index 0bae55b..45b7d08 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -1082,7 +1082,7 @@ class config(object):
                """Validate miscellaneous settings and display warnings if 
necessary.
                (This code was previously in the global scope of portage.py)"""
 
-               groups = self["ACCEPT_KEYWORDS"].split()
+               groups = self.get("ACCEPT_KEYWORDS", "").split()
                archlist = self.archlist()
                if not archlist:
                        writemsg(_("--- 'profiles/arch.list' is empty or "
@@ -1976,7 +1976,7 @@ class config(object):
                # doesn't work properly as negative values are lost in the 
config
                # object (bug #139600)
                backuped_accept_keywords = 
self.configdict["backupenv"].get("ACCEPT_KEYWORDS", "")
-               global_accept_keywords = self["ACCEPT_KEYWORDS"]
+               global_accept_keywords = self.get("ACCEPT_KEYWORDS", "")
 
                return self._keywords_manager.getMissingKeywords(cpv, 
metadata["SLOT"], \
                        metadata.get("KEYWORDS", ""), 
metadata.get('repository'), \

Reply via email to