From: Zac Medico <zmedico@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: Zac Medico <zmedico@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH v2] search._xmatch: handle aux_get KeyError (525718)
Date: Thu, 11 Dec 2014 00:33:41 -0800 [thread overview]
Message-ID: <1418286821-18908-1-git-send-email-zmedico@gentoo.org> (raw)
In-Reply-To: <1418284304-10683-1-git-send-email-zmedico@gentoo.org>
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
---
PATCH v2 splits out a _aux_get_error method to unify the error output
formatting.
pym/_emerge/search.py | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py
index 90dbcec..e7f6f44 100644
--- a/pym/_emerge/search.py
+++ b/pym/_emerge/search.py
@@ -1,6 +1,8 @@
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+from __future__ import unicode_literals
+
import re
import portage
from portage import os
@@ -86,6 +88,11 @@ class search(object):
pass
raise KeyError(args[0])
+ def _aux_get_error(self, cpv):
+ portage.writemsg("emerge: search: "
+ "aux_get('%s') failed, skipping\n" % cpv,
+ noiselevel=-1)
+
def _findname(self, *args, **kwargs):
for db in self._dbs:
if db is not self._portdb:
@@ -166,8 +173,12 @@ 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:
+ self._aux_get_error(cpv)
+ continue
if not self._visible(db, cpv, metadata):
continue
matches.add(cpv)
@@ -197,8 +208,12 @@ 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:
+ self._aux_get_error(cpv)
+ continue
if not self._visible(db, cpv, metadata):
continue
if not result or cpv == portage.best([cpv, result]):
@@ -257,9 +272,7 @@ class search(object):
full_desc = self._aux_get(
full_package, ["DESCRIPTION"])[0]
except KeyError:
- portage.writemsg(
- "emerge: search: aux_get() failed, skipping\n",
- noiselevel=-1)
+ self._aux_get_error(full_package)
continue
if not self.searchre.search(full_desc):
continue
@@ -337,7 +350,7 @@ class search(object):
metadata = dict(zip(metadata_keys,
self._aux_get(full_package, metadata_keys)))
except KeyError:
- msg.append("emerge: search: aux_get() failed, skipping\n")
+ self._aux_get_error(full_package)
continue
desc = metadata["DESCRIPTION"]
--
2.0.4
next prev parent reply other threads:[~2014-12-11 8:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-11 7:51 [gentoo-portage-dev] [PATCH] search._xmatch: handle aux_get KeyError (525718) Zac Medico
2014-12-11 8:08 ` Alexander Berntsen
2014-12-11 8:33 ` Zac Medico [this message]
2014-12-11 8:36 ` [gentoo-portage-dev] [PATCH v2] " 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=1418286821-18908-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