aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-01-28 21:18:00 (GMT)
committerZac Medico <zmedico@gentoo.org>2013-01-28 21:19:10 (GMT)
commitcefaa921a68c017910a804c6f889f6f19fc6e8b9 (patch)
tree3cc142ce7cbd42032b872a417d6b7a06eb468d49
parentportage(5): improve layout.conf documentation (diff)
downloadportage-cefaa921a68c017910a804c6f889f6f19fc6e8b9.zip
portage-cefaa921a68c017910a804c6f889f6f19fc6e8b9.tar.gz
portage-cefaa921a68c017910a804c6f889f6f19fc6e8b9.tar.bz2
removeFromContents: avoid KeyError, bug #454400
It's possible for two different paths to refer to the same contents_key, due to directory symlinks. This could happen if a directory was changed to a symlink after a package was merged, either by the user or by a pkg_* phase from some random ebuild.
-rw-r--r--pym/portage/dbapi/vartree.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index bbcf61c..a2fbf86 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -1002,7 +1002,11 @@ class vardbapi(dbapi):
relative_filename = filename[root_len:]
contents_key = pkg._match_contents(relative_filename)
if contents_key:
- del new_contents[contents_key]
+ # It's possible for two different paths to refer to the same
+ # contents_key, due to directory symlinks. Therefore, pass a
+ # default value to pop, in order to avoid a KeyError which
+ # could otherwise be triggered (see bug #454400).
+ new_contents.pop(contents_key, None)
removed += 1
if removed: