summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-22 18:54:27 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-22 18:54:27 +0000
commitcee4de48aae88c5df32e147784fd53ab5fb3ea09 (patch)
treeffe8ce683840493604b13f5ffd20f2d5f87bd7d4
parent443217dc61b0d112babf2a5f8e938b6058ff3a83 (diff)
downloadportage-cee4de48aae88c5df32e147784fd53ab5fb3ea09.tar.gz
portage-cee4de48aae88c5df32e147784fd53ab5fb3ea09.tar.bz2
portage-cee4de48aae88c5df32e147784fd53ab5fb3ea09.zip
For python 3.x with boolean target, len() results in TypeError, so
make __len__ return 0 or 1 in this case. svn path=/main/trunk/; revision=14377
-rw-r--r--pym/portage/proxy/objectproxy.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pym/portage/proxy/objectproxy.py b/pym/portage/proxy/objectproxy.py
index 00c5076d1..6dffff7d5 100644
--- a/pym/portage/proxy/objectproxy.py
+++ b/pym/portage/proxy/objectproxy.py
@@ -45,7 +45,15 @@ class ObjectProxy(object):
return iter(object.__getattribute__(self, '_get_target')())
def __len__(self):
- return len(object.__getattribute__(self, '_get_target')())
+ try:
+ return len(object.__getattribute__(self, '_get_target')())
+ except TypeError:
+ # For python 3.x with boolean target, len() results in
+ # TypeError, so return 0 or 1.
+ if bool(object.__getattribute__(self, '_get_target')()):
+ return 1
+ else:
+ return 0
def __repr__(self):
return repr(object.__getattribute__(self, '_get_target')())