[pyatspi2] Fix truth evaluation for accessibles in Python 3



commit 9c5dacb7717db8f92451c24733b7ba6dd3081785
Author: Mike Gorse <mgorse suse com>
Date:   Wed Jun 20 10:57:39 2012 -0500

    Fix truth evaluation for accessibles in Python 3
    
    __nonzero__ was renamed to __bool__ in Python 3. Override both for portability. Since we override __len__, it is used as the truth value unless we also override __nonzero__/__bool__.

 pyatspi/Accessibility.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/pyatspi/Accessibility.py b/pyatspi/Accessibility.py
index 7f24fbd..28abcee 100644
--- a/pyatspi/Accessibility.py
+++ b/pyatspi/Accessibility.py
@@ -149,6 +149,7 @@ Atspi.Accessible.getAttributes = Atspi.Accessible.get_attributes_as_array
 Atspi.Accessible.getApplication = Atspi.Accessible.get_application
 Atspi.Accessible.__getitem__ = Accessible_getitem
 Atspi.Accessible.__len__ = Atspi.Accessible.get_child_count
+Atspi.Accessible.__bool__ = lambda x: True
 Atspi.Accessible.__nonzero__ = lambda x: True
 Atspi.Accessible.__str__ = Accessible_str
 Atspi.Accessible.childCount = property(fget=Atspi.Accessible.get_child_count)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]