[orca] Fix for bug 658133 - Firefox lines which begin with bullets are not always presented by Orca



commit f048d881c1516814237e85a31226c357a8102b28
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Sat Sep 3 12:29:01 2011 -0400

    Fix for bug 658133 - Firefox lines which begin with bullets are not always presented by Orca

 src/orca/braille.py                       |    7 ++++++-
 src/orca/debug.py                         |   12 ++++++++++--
 src/orca/script_utilities.py              |   12 ++++++++++--
 src/orca/scripts/toolkits/Gecko/script.py |   16 +++++++++++++---
 src/orca/speechdispatcherfactory.py       |    5 ++++-
 5 files changed, 43 insertions(+), 9 deletions(-)
---
diff --git a/src/orca/braille.py b/src/orca/braille.py
index 923b8c8..ebb0844 100644
--- a/src/orca/braille.py
+++ b/src/orca/braille.py
@@ -351,9 +351,14 @@ class Region:
 
         self.expandOnCursor = expandOnCursor
 
+        try:
+            string = string.decode("UTF-8")
+        except UnicodeEncodeError:
+            debug.printException(debug.LEVEL_SEVERE)
+
         # The uncontracted string for the line.
         #
-        self.rawLine = string.decode("UTF-8").strip("\n")
+        self.rawLine = string.strip("\n")
 
         if self.contracted:
             self.contractionTable = settings.brailleContractionTable or \
diff --git a/src/orca/debug.py b/src/orca/debug.py
index 1bcef7e..7eba99d 100644
--- a/src/orca/debug.py
+++ b/src/orca/debug.py
@@ -197,9 +197,17 @@ def println(level, text = ""):
 
     if level >= debugLevel:
         if debugFile:
-            debugFile.writelines([text, "\n"])
+            try:
+                debugFile.writelines([text, "\n"])
+            except TypeError:
+                text = "TypeError when trying to write text"
+                debugFile.writelines([text, "\n"])
         else:
-            sys.stderr.writelines([text, "\n"])
+            try:
+                sys.stderr.writelines([text, "\n"])
+            except TypeError:
+                text = "TypeError when trying to write text"
+                sys.stderr.writelines([text, "\n"])
 
 def printObjectEvent(level, event, sourceInfo=None):
     """Prints out an Python Event object.  The given level may be
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 587b7d5..3ff2675 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2447,7 +2447,12 @@ class Utilities:
         """
 
         newLine = ""
-        words = self.WORDS_RE.split(line.decode("UTF-8"))
+        try:
+            line = line.decode("UTF-8")
+        except UnicodeEncodeError:
+            pass
+
+        words = self.WORDS_RE.split(line)
         for word in words:
             if word.isalnum():
                 word = self._pronunciationForSegment(word)
@@ -2480,7 +2485,10 @@ class Utilities:
         Returns: a new line adjusted for repeat character counts (if enabled).
         """
 
-        line = line.decode("UTF-8")
+        try:
+            line = line.decode("UTF-8")
+        except UnicodeEncodeError:
+            pass
 
         if (len(line) < 4) or (settings.repeatCharacterLimit < 4):
             return line.encode("UTF-8")
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index 84563fe..9f6bc05 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -4979,7 +4979,11 @@ class Script(default.Script):
                 # So far so good. If the line doesn't begin with an EOC, we
                 # have our first character for this object.
                 #
-                if not line.startswith(self.EMBEDDED_OBJECT_CHARACTER):
+                try:
+                    isEOC = line.startswith(self.EMBEDDED_OBJECT_CHARACTER)
+                except:
+                    isEOC = False
+                if not isEOC:
                     offset = start
                 else:
                     # The line may begin with a link, or it may begin with
@@ -5154,11 +5158,17 @@ class Script(default.Script):
     #
     def getACSS(self, obj, string):
         """Returns the ACSS to speak anything for the given obj."""
+
+        try:
+            string = string.decode("UTF-8")
+        except UnicodeEncodeError:
+            pass
+
         if obj.getRole() == pyatspi.ROLE_LINK:
             acss = self.voices[settings.HYPERLINK_VOICE]
         elif string and isinstance(string, basestring) \
-            and string.decode("UTF-8").isupper() \
-            and string.decode("UTF-8").strip().isalpha():
+            and string.isupper() \
+            and string.strip().isalpha():
             acss = self.voices[settings.UPPERCASE_VOICE]
         else:
             acss = self.voices[settings.DEFAULT_VOICE]
diff --git a/src/orca/speechdispatcherfactory.py b/src/orca/speechdispatcherfactory.py
index 5526a3f..7373d9b 100644
--- a/src/orca/speechdispatcherfactory.py
+++ b/src/orca/speechdispatcherfactory.py
@@ -286,7 +286,10 @@ class SpeechServer(speechserver.SpeechServer):
         #
         spokenEllipsis = _(" dot dot dot")
         newText = re.sub(ELLIPSIS, spokenEllipsis, oldText)
-        newText = newText.decode("UTF-8")
+        try:
+            newText = newText.decode("UTF-8")
+        except UnicodeEncodeError:
+            pass
 
         symbols = set(re.findall(PUNCTUATION, newText))
         for symbol in symbols:



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