Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/
Date: Mon, 28 Jan 2013 21:19:23
Message-Id: 1359407950.cefaa921a68c017910a804c6f889f6f19fc6e8b9.zmedico@gentoo
1 commit: cefaa921a68c017910a804c6f889f6f19fc6e8b9
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Mon Jan 28 21:18:00 2013 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Mon Jan 28 21:19:10 2013 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=cefaa921
7
8 removeFromContents: avoid KeyError, bug #454400
9
10 It's possible for two different paths to refer to the same
11 contents_key, due to directory symlinks. This could happen if a
12 directory was changed to a symlink after a package was merged, either
13 by the user or by a pkg_* phase from some random ebuild.
14
15 ---
16 pym/portage/dbapi/vartree.py | 6 +++++-
17 1 files changed, 5 insertions(+), 1 deletions(-)
18
19 diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
20 index bbcf61c..a2fbf86 100644
21 --- a/pym/portage/dbapi/vartree.py
22 +++ b/pym/portage/dbapi/vartree.py
23 @@ -1002,7 +1002,11 @@ class vardbapi(dbapi):
24 relative_filename = filename[root_len:]
25 contents_key = pkg._match_contents(relative_filename)
26 if contents_key:
27 - del new_contents[contents_key]
28 + # It's possible for two different paths to refer to the same
29 + # contents_key, due to directory symlinks. Therefore, pass a
30 + # default value to pop, in order to avoid a KeyError which
31 + # could otherwise be triggered (see bug #454400).
32 + new_contents.pop(contents_key, None)
33 removed += 1
34
35 if removed: