public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Zac Medico <zmedico@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: Zac Medico <zmedico@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH] search._xmatch: handle aux_get KeyError (525718)
Date: Wed, 10 Dec 2014 23:51:44 -0800	[thread overview]
Message-ID: <1418284304-10683-1-git-send-email-zmedico@gentoo.org> (raw)

Since commit 55c8c8bc7a781e3f71ce92922eea64ad4cafce3c, emerge --search
can raise an unhandled KeyError if a pkg_desc_index contains a stale
package. Handle it with the same error message used for other aux_get
failures.

Fixes: 55c8c8bc7a78 ("Add emerge --search-index option.")
X-Gentoo-Bug: 525718
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=525718
---
 pym/_emerge/search.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py
index 90dbcec..76adcea 100644
--- a/pym/_emerge/search.py
+++ b/pym/_emerge/search.py
@@ -166,8 +166,14 @@ class search(object):
 				else:
 					db_keys = list(db._aux_cache_keys)
 					for cpv in db.match(atom):
-						metadata = zip(db_keys,
-							db.aux_get(cpv, db_keys))
+						try:
+							metadata = zip(db_keys,
+								db.aux_get(cpv, db_keys))
+						except KeyError:
+							portage.writemsg("emerge: search: "
+								"aux_get() failed, skipping\n",
+								noiselevel=-1)
+							continue
 						if not self._visible(db, cpv, metadata):
 							continue
 						matches.add(cpv)
@@ -197,8 +203,14 @@ class search(object):
 					for cpv in reversed(matches):
 						if portage.cpv_getkey(cpv) != cp:
 							continue
-						metadata = zip(db_keys,
-							db.aux_get(cpv, db_keys))
+						try:
+							metadata = zip(db_keys,
+								db.aux_get(cpv, db_keys))
+						except KeyError:
+							portage.writemsg("emerge: search: "
+								"aux_get() failed, skipping\n",
+								noiselevel=-1)
+							continue
 						if not self._visible(db, cpv, metadata):
 							continue
 						if not result or cpv == portage.best([cpv, result]):
-- 
2.0.4



             reply	other threads:[~2014-12-11  7:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-11  7:51 Zac Medico [this message]
2014-12-11  8:08 ` [gentoo-portage-dev] [PATCH] search._xmatch: handle aux_get KeyError (525718) Alexander Berntsen
2014-12-11  8:33 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
2014-12-11  8:36   ` Alexander Berntsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418284304-10683-1-git-send-email-zmedico@gentoo.org \
    --to=zmedico@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox