Remove ugly code from __len__, since defining __bool__ fixes the same
authorZac Medico <zmedico@gentoo.org>
Fri, 25 Sep 2009 07:00:41 +0000 (07:00 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 25 Sep 2009 07:00:41 +0000 (07:00 -0000)
issue.

svn path=/main/trunk/; revision=14428

pym/portage/proxy/objectproxy.py

index dff4a07f75350ad842c7a0101b6489e91294b3e8..a064d705668739482fa25325a45f92e6c07eedc0 100644 (file)
@@ -47,15 +47,7 @@ class ObjectProxy(object):
                return iter(object.__getattribute__(self, '_get_target')())
 
        def __len__(self):
-               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
+               return len(object.__getattribute__(self, '_get_target')())
 
        def __repr__(self):
                return repr(object.__getattribute__(self, '_get_target')())