summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-07-26 22:08:52 -0700
committerZac Medico <zmedico@gentoo.org>2010-07-26 22:08:52 -0700
commitd0e0abf9314bf0e2baa6b11a152751a2231fcd5e (patch)
tree1a947c295e9e1e2862a692fd9d610d46654bb5ea
parent0faca588d881865be6eafc9b6401124bb927bee5 (diff)
downloadportage-d0e0abf9314bf0e2baa6b11a152751a2231fcd5e.tar.gz
portage-d0e0abf9314bf0e2baa6b11a152751a2231fcd5e.tar.bz2
portage-d0e0abf9314bf0e2baa6b11a152751a2231fcd5e.zip
Make ExtendedAtomDict inherit from MutableMapping, and fix __getitem__
to raise KeyError if given a non-string argument.
-rw-r--r--pym/portage/dep/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index a8c647cee..25cad8fd8 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -770,13 +770,16 @@ def extended_cp_match(extended_cp, other_cp):
_extended_cp_re_cache[extended_cp] = extended_cp_re
return extended_cp_re.match(other_cp) is not None
-class ExtendedAtomDict(object):
+class ExtendedAtomDict(portage.cache.mappings.MutableMapping):
"""
dict() wrapper that supports extended atoms as keys and allows lookup
of a normal cp against other normal cp and extended cp.
The value type has to be given to __init__ and is assumed to be the same
for all values.
"""
+
+ __slots__ = ('_extended', '_normal', '_value_class')
+
def __init__(self, value_class):
self._extended = {}
self._normal = {}
@@ -817,6 +820,8 @@ class ExtendedAtomDict(object):
self._normal[cp] = val
def __getitem__(self, cp):
+ if not isinstance(cp, basestring):
+ raise KeyError(cp)
if "*" in cp:
return self._extended[cp]
else: