[orca] Add handling for RuntimeError now that we get them from pyatspi2



commit 8fc1fbb19c7d4f46a34fd3812f5d8b0aefec9d68
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Mon Feb 6 16:29:54 2012 -0500

    Add handling for RuntimeError now that we get them from pyatspi2

 src/orca/debug.py                         |    2 +-
 src/orca/event_manager.py                 |    8 ++++----
 src/orca/flat_review.py                   |    2 +-
 src/orca/generator.py                     |    2 +-
 src/orca/label_inference.py               |    2 +-
 src/orca/script.py                        |    8 ++++----
 src/orca/script_utilities.py              |   18 +++++++++---------
 src/orca/scripts/default.py               |    4 ++--
 src/orca/scripts/toolkits/Gecko/script.py |    8 ++++----
 9 files changed, 27 insertions(+), 27 deletions(-)
---
diff --git a/src/orca/debug.py b/src/orca/debug.py
index de33686..7c44b59 100644
--- a/src/orca/debug.py
+++ b/src/orca/debug.py
@@ -283,7 +283,7 @@ def getAccessibleDetails(level, acc, indent="", includeApp=True):
         if app:
             try:
                 string = indent + "app.name='%s' " % app.name
-            except LookupError:
+            except (LookupError, RuntimeError):
                 string = indent + "app.name='<error getting name>' "
         else:
             string = indent + "app=None "
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index ea3fa53..4263bc4 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -415,12 +415,12 @@ class EventManager:
         role = state = None
         try:
             role = event.source.getRole()
-        except LookupError:
-            return False, "LookupError getting event.source's role"
+        except (LookupError, RuntimeError):
+            return False, "Error getting event.source's role"
         try:
             state = event.source.getState()
-        except LookupError:
-            return False, "LookupError getting event.source's state"
+        except (LookupError, RuntimeError):
+            return False, "Error getting event.source's state"
         
         if not script:
             script = self._getScriptForEvent(event)
diff --git a/src/orca/flat_review.py b/src/orca/flat_review.py
index e92f0c9..533f97a 100644
--- a/src/orca/flat_review.py
+++ b/src/orca/flat_review.py
@@ -1271,7 +1271,7 @@ class Context:
         #
         try:
             childCount = root.childCount
-        except LookupError:
+        except (LookupError, RuntimeError):
             childCount = -1
         if root.childCount <= 0:
             return self.getZonesFromAccessible(root, rootexts)
diff --git a/src/orca/generator.py b/src/orca/generator.py
index f821a2e..63494d2 100644
--- a/src/orca/generator.py
+++ b/src/orca/generator.py
@@ -304,7 +304,7 @@ class Generator:
         else:
             try:
                 description = obj.description
-            except LookupError:
+            except (LookupError, RuntimeError):
                 return result
             if description:
                 result.append(description)
diff --git a/src/orca/label_inference.py b/src/orca/label_inference.py
index b89fab8..4d65e56 100644
--- a/src/orca/label_inference.py
+++ b/src/orca/label_inference.py
@@ -133,7 +133,7 @@ class LabelInference:
 
         try:
             children = [child for child in obj]
-        except LookupError:
+        except (LookupError, RuntimeError):
             debug.println(debug.LEVEL_FINE, 'Dead Accessible in %s' % obj)
             return False
 
diff --git a/src/orca/script.py b/src/orca/script.py
index d3b9d85..99b7d18 100644
--- a/src/orca/script.py
+++ b/src/orca/script.py
@@ -73,8 +73,8 @@ class Script:
         if app:
             try:
                 self.name = self.app.name
-            except LookupError:
-                msg = 'script.__init__: LookupError trying to get app.name'
+            except (LookupError, RuntimeError):
+                msg = 'script.__init__: Error trying to get app.name'
                 debug.println(debug.LEVEL_FINE, msg)
                 self.name = "default"
         else:
@@ -365,8 +365,8 @@ class Script:
 
         try:
             role = event.source.getRole()
-        except LookupError:
-            msg = 'script.processObjectEvent: LookupError getting role'
+        except (LookupError, RuntimeError):
+            msg = 'script.processObjectEvent: Error getting role'
             debug.println(debug.LEVEL_FINE, msg)
             return
 
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 59a1a42..dc11195 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -595,7 +595,7 @@ class Utilities:
         if not displayedText:
             try:
                 displayedText = obj.name
-            except LookupError:
+            except (LookupError, RuntimeError):
                 pass
 
         # [[[WDW - HACK because push buttons can have labels as their
@@ -800,8 +800,8 @@ class Utilities:
 
         try:
             role = obj.getRole()
-        except LookupError:
-            debug.println(debug.LEVEL_FINE, 'LookupError - isLink getting role')
+        except (LookupError, RuntimeError):
+            debug.println(debug.LEVEL_FINE, 'Error - isLink getting role')
             return False
 
         return role == pyatspi.ROLE_LINK
@@ -2946,22 +2946,22 @@ class Utilities:
         # "The reports of my implementation are greatly exaggerated."
         try:
             maxValue = value.maximumValue
-        except LookupError:
+        except (LookupError, RuntimeError):
             maxValue = 0.0
             debug.println(debug.LEVEL_FINEST, "VALUE WARNING: " \
-                          "LookupError accessing maximumValue for %s" % obj)
+                          "Error accessing maximumValue for %s" % obj)
         try:
             minValue = value.minimumValue
-        except LookupError:
+        except (LookupError, RuntimeError):
             minValue = 0.0
             debug.println(debug.LEVEL_FINEST, "VALUE WARNING: " \
-                          "LookupError accessing minimumValue for %s" % obj)
+                          "Error accessing minimumValue for %s" % obj)
         try:
             minIncrement = value.minimumIncrement
-        except LookupError:
+        except (LookupError, RuntimeError):
             minIncrement = (maxValue - minValue) / 100.0
             debug.println(debug.LEVEL_FINEST, "VALUE WARNING: " \
-                          "LookupError accessing minimumIncrement for %s" % obj)
+                          "Error accessing minimumIncrement for %s" % obj)
 
         try:
             decimalPlaces = math.ceil(max(0, -math.log10(minIncrement)))
diff --git a/src/orca/scripts/default.py b/src/orca/scripts/default.py
index db81191..53e2ee3 100644
--- a/src/orca/scripts/default.py
+++ b/src/orca/scripts/default.py
@@ -1390,7 +1390,7 @@ class Script(script.Script):
         #
         try:
             relations = obj.getRelationSet()
-        except LookupError:
+        except (LookupError, RuntimeError):
             relations = []
         for relation in relations:
             if relation.getRelationType() \
@@ -3047,7 +3047,7 @@ class Script(script.Script):
         #
         try:
             role = orca_state.locusOfFocus.getRole()
-        except LookupError:
+        except (LookupError, RuntimeError):
             role = None
         if role in [pyatspi.ROLE_FRAME, pyatspi.ROLE_DIALOG]:
             frameApp = orca_state.locusOfFocus.getApplication()
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index da551f1..e697b2c 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -2007,11 +2007,11 @@ class Script(default.Script):
             #
             try:
                 role = candidate.getRole()
-            except LookupError:
+            except (LookupError, RuntimeError):
                 role = None
             try:
                 state = candidate.getState()
-            except LookupError:
+            except (LookupError, RuntimeError):
                 state = pyatspi.StateSet()
             if role in [pyatspi.ROLE_LIST, pyatspi.ROLE_COMBO_BOX] \
                and state.contains(pyatspi.STATE_FOCUSABLE) \
@@ -5415,7 +5415,7 @@ class Script(default.Script):
             if obj and not self._objectForFocusGrab:
                 try:
                     obj.queryComponent().grabFocus()
-                except LookupError:
+                except (LookupError, RuntimeError):
                     pass
 
             if self._objectForFocusGrab:
@@ -5431,7 +5431,7 @@ class Script(default.Script):
                 #    objectForFocus = objectForFocus.parent
                 try:
                     self._objectForFocusGrab.queryComponent().grabFocus()
-                except LookupError:
+                except (LookupError, RuntimeError):
                     pass
 
         text = self.utilities.queryNonEmptyText(obj)



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