diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-02-04 23:30:42 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-02-04 23:30:42 +0000 |
commit | 4f0265acc0a894c615eacce760ddfa09a970b048 (patch) | |
tree | 7e4845688b11cae3cb87dbb97c2ce7b80c84bc25 /pym/portage/cache/mappings.py | |
parent | dee77a2557fe0d8dbf83550a0eb5b1c8e136962c (diff) | |
download | portage-4f0265acc0a894c615eacce760ddfa09a970b048.tar.gz portage-4f0265acc0a894c615eacce760ddfa09a970b048.tar.bz2 portage-4f0265acc0a894c615eacce760ddfa09a970b048.zip |
For python-3.0 compatibility, make dict-like classes modify their keys(),
items(), and values() methods appropriatly for the current python version.
svn path=/main/trunk/; revision=12584
Diffstat (limited to 'pym/portage/cache/mappings.py')
-rw-r--r-- | pym/portage/cache/mappings.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pym/portage/cache/mappings.py b/pym/portage/cache/mappings.py index 112301476..010eb7f8e 100644 --- a/pym/portage/cache/mappings.py +++ b/pym/portage/cache/mappings.py @@ -3,6 +3,7 @@ # License: GPL2 # $Id$ +import sys import UserDict import warnings import weakref @@ -65,6 +66,10 @@ class ProtectedDict(UserDict.DictMixin): DeprecationWarning) return key in self + if sys.hexversion >= 0x3000000: + keys = __iter__ + items = iteritems + class LazyLoad(UserDict.DictMixin): """ Lazy loading of values for a dict @@ -111,6 +116,10 @@ class LazyLoad(UserDict.DictMixin): self.pull = None return key in self.d + if sys.hexversion >= 0x3000000: + keys = __iter__ + items = iteritems + _slot_dict_classes = weakref.WeakValueDictionary() def slot_dict_class(keys, prefix="_val_"): @@ -265,6 +274,11 @@ def slot_dict_class(keys, prefix="_val_"): def __str__(self): return str(dict(self.iteritems())) + if sys.hexversion >= 0x3000000: + items = iteritems + keys = __iter__ + values = itervalues + v = SlotDict _slot_dict_classes[v.allowed_keys] = v return v |