[orca] Handle some string encoding issues we weren't; stop printing tracebacks for exceptions we're handlin
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Handle some string encoding issues we weren't; stop printing tracebacks for exceptions we're handlin
- Date: Sat, 25 Feb 2012 17:46:18 +0000 (UTC)
commit b8920d3fdd0fb6856a4c9dbc29ba030a78b616b9
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Sat Feb 25 12:45:03 2012 -0500
Handle some string encoding issues we weren't; stop printing tracebacks for exceptions we're handling
src/orca/liveregions.py | 4 ++++
src/orca/script_utilities.py | 13 ++++++++-----
src/orca/scripts/toolkits/Gecko/script.py | 24 +++++++++++++++++-------
3 files changed, 29 insertions(+), 12 deletions(-)
---
diff --git a/src/orca/liveregions.py b/src/orca/liveregions.py
index d246b65..9f80951 100644
--- a/src/orca/liveregions.py
+++ b/src/orca/liveregions.py
@@ -436,6 +436,10 @@ class LiveRegionManager:
# We found an embed character. We can expect a children-changed
# event, which we will act on, so just return.
txt = sourceitext.getText(0, -1)
+ try:
+ txt = txt.decode("UTF-8")
+ except UnicodeEncodeError:
+ pass
if txt.count(self._script.EMBEDDED_OBJECT_CHARACTER) > 0:
return None
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 795b5bd..e4ed43e 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -1715,20 +1715,20 @@ class Utilities:
accessible text, or -1 something was amuck.
"""
+ offset = -1
try:
hyperlink = obj.queryHyperlink()
except NotImplementedError:
- offset = -1
+ pass
else:
# We need to make sure that this is an embedded object in
# some accessible text (as opposed to an imagemap link).
#
try:
obj.parent.queryText()
- except NotImplementedError:
- offset = -1
- else:
offset = hyperlink.startIndex
+ except:
+ pass
return offset
@@ -1782,7 +1782,10 @@ class Utilities:
childText = self.expandEOCs(child)
if not childText:
childText = ""
- toBuild[index] = childText.decode("UTF-8")
+ try:
+ toBuild[index] = childText.decode("UTF-8")
+ except UnicodeEncodeError:
+ toBuild[index] = childText
string = "".join(toBuild)
return string
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 1888545..2ddd1b6 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -3263,7 +3263,7 @@ class Script(default.Script):
try:
state = obj.getState()
except:
- debug.printException(debug.LEVEL_WARNING)
+ pass
return False
else:
return state.contains(pyatspi.STATE_SHOWING) \
@@ -3306,6 +3306,10 @@ class Script(default.Script):
text = self.utilities.queryNonEmptyText(documentFrame)
if text:
char = text.getText(text.characterCount - 1, text.characterCount)
+ try:
+ char = char.decode("UTF-8")
+ except UnicodeEncodeError:
+ pass
if char != self.EMBEDDED_OBJECT_CHARACTER:
return [documentFrame, text.characterCount - 1]
@@ -3320,6 +3324,10 @@ class Script(default.Script):
if text:
char = text.getText(text.characterCount - 1,
text.characterCount)
+ try:
+ char = char.decode("UTF-8")
+ except UnicodeEncodeError:
+ pass
if char != self.EMBEDDED_OBJECT_CHARACTER:
return [obj.parent, text.characterCount - 1]
@@ -3591,7 +3599,6 @@ class Script(default.Script):
try:
summary = self._collectionPageSummary()
except:
- debug.printException(debug.LEVEL_SEVERE)
summary = self._iterativePageSummary(obj)
else:
summary = self._iterativePageSummary(obj)
@@ -4258,7 +4265,10 @@ class Script(default.Script):
if unicodeText[nextOffset] != self.EMBEDDED_OBJECT_CHARACTER:
return [obj, nextOffset]
elif obj.childCount:
- child = obj[self.getChildIndex(obj, nextOffset)]
+ try:
+ child = obj[self.getChildIndex(obj, nextOffset)]
+ except:
+ break
if child:
return self.findNextCaretInOrder(child,
-1,
@@ -4278,7 +4288,7 @@ class Script(default.Script):
-1,
includeNonText)
except:
- debug.printException(debug.LEVEL_SEVERE)
+ pass
elif includeNonText and (startOffset < 0) \
and (not self.utilities.isLayoutOnly(obj)):
@@ -4309,7 +4319,7 @@ class Script(default.Script):
-1,
includeNonText)
except:
- debug.printException(debug.LEVEL_SEVERE)
+ pass
obj = obj.parent
return [None, -1]
@@ -4389,7 +4399,7 @@ class Script(default.Script):
-1,
includeNonText)
except:
- debug.printException(debug.LEVEL_SEVERE)
+ pass
elif includeNonText and (startOffset < 0) \
and (not self.utilities.isLayoutOnly(obj)):
@@ -4420,7 +4430,7 @@ class Script(default.Script):
-1,
includeNonText)
except:
- debug.printException(debug.LEVEL_SEVERE)
+ pass
obj = obj.parent
return [None, -1]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]