freeze break request: fix pyatspi.getState().getStates()



AT-SPI has a method to return the list of states contained in a state set as an array, but this sometimes fails with pyatspi on 64-bit architectures because of what I think is a bug in pygi. In any case, pygi is copying an argument from an array (an int in this case) and later assuming that it has a valid long value, so it might read eight bytes where only four were initialized. I've filed the issue as BGO#646581. I would like to apply the attached patch to pyatspi for the time being; it works around the issue by not making the problematic C call.

Thanks,
-Mike
diff --git a/pyatspi/state.py b/pyatspi/state.py
index 33f3256..90cbdc8 100644
--- a/pyatspi/state.py
+++ b/pyatspi/state.py
@@ -162,8 +162,16 @@ def stateset_init(self, *states):
 	GObject.GObject.__init__(self)
 	map(self.add, states)
 
+# TODO: Eventually remove this function when BGO#646581 is resolved
+def StateSet_getStates(self):
+        ret = []
+        for i in range(0, 64):
+                if (self.states & (1 << i)):
+                        ret.append(Atspi.StateType(i))
+        return ret
+
 StateSet = Atspi.StateSet
-StateSet.getStates = StateSet.get_states
+StateSet.getStates = StateSet_getStates
 StateSet.isEmpty = StateSet.is_empty
 StateSet.raw = lambda x: x
 StateSet.unref = lambda x: None


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