[orca] Fix for bug 665769 - Preferences not saved or restored correctly due to comparing unicode and utf-8
- From: Joanmarie Diggs <joanied src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [orca] Fix for bug 665769 - Preferences not saved or restored correctly due to comparing unicode and utf-8
- Date: Thu, 8 Dec 2011 20:33:25 +0000 (UTC)
commit 9719ce4788d96758dbab6e117e8fdc8379959e75
Author: Joanmarie Diggs <jdiggs igalia com>
Date: Thu Dec 8 15:31:39 2011 -0500
Fix for bug 665769 - Preferences not saved or restored correctly due to comparing unicode and utf-8 strings
src/orca/orca_gui_prefs.py | 10 ++++++++++
src/orca/script_utilities.py | 10 +++++-----
src/orca/settings_manager.py | 2 ++
src/orca/speechdispatcherfactory.py | 2 ++
4 files changed, 19 insertions(+), 5 deletions(-)
---
diff --git a/src/orca/orca_gui_prefs.py b/src/orca/orca_gui_prefs.py
index 864bf24..696299a 100644
--- a/src/orca/orca_gui_prefs.py
+++ b/src/orca/orca_gui_prefs.py
@@ -687,6 +687,9 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
if len(self.speechFamiliesChoices) == 0:
return
+ if isinstance(familyName, unicode):
+ familyName = familyName.encode('UTF-8')
+
valueSet = False
i = 0
for family in self.speechFamiliesChoices:
@@ -796,6 +799,11 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
if not serverInfo:
serverInfo = speech.getInfo()
+ try:
+ serverInfo = map(lambda x: x.encode('UTF-8'), serverInfo)
+ except (UnicodeDecodeError, UnicodeEncodeError):
+ pass
+
valueSet = False
i = 0
for server in self.speechServersChoices:
@@ -1569,6 +1577,8 @@ class OrcaSetupGUI(orca_gtkbuilder.GtkBuilderWrapper):
sdtime(settings.TIME_FORMAT_24_HM_WITH_WORDS, ltime())])
indextime = TIME_FORMAT_LOCALE
timeFormat = self.prefsDict["presentTimeFormat"]
+ if isinstance(timeFormat, unicode):
+ timeFormat = timeFormat.encode('UTF-8')
if timeFormat == settings.TIME_FORMAT_LOCALE:
indextime = TIME_FORMAT_LOCALE
elif timeFormat == settings.TIME_FORMAT_24_HMS:
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index dea3136..bde8292 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2450,12 +2450,12 @@ class Utilities:
newSegment = pronunciation_dict.getPronunciation(
segment, self._script.app_pronunciation_dict)
- try:
- unchanged = newSegment == segment
- except (UnicodeEncodeError, UnicodeDecodeError):
- unchanged = True
+ if isinstance(segment, unicode):
+ segment = segment.encode('UTF-8')
+ if isinstance(newSegment, unicode):
+ newSegment = newSegment.encode('UTF-8')
- if unchanged:
+ if newSegment == segment:
newSegment = pronunciation_dict.getPronunciation(segment)
return newSegment
diff --git a/src/orca/settings_manager.py b/src/orca/settings_manager.py
index cba7e09..da13747 100644
--- a/src/orca/settings_manager.py
+++ b/src/orca/settings_manager.py
@@ -367,6 +367,8 @@ class SettingsManager(object):
self.profileGeneral = {}
for key, value in general.items():
+ if isinstance(value, unicode):
+ value = value.encode('UTF-8')
if key in settings.excludeKeys:
continue
elif key == 'profile':
diff --git a/src/orca/speechdispatcherfactory.py b/src/orca/speechdispatcherfactory.py
index 17a4a2d..06dee62 100644
--- a/src/orca/speechdispatcherfactory.py
+++ b/src/orca/speechdispatcherfactory.py
@@ -249,6 +249,8 @@ class SpeechServer(speechserver.SpeechServer):
pass
else:
name = acss_family.get(speechserver.VoiceFamily.NAME)
+ if isinstance(name, unicode):
+ name = name.encode('UTF-8')
if name != self._default_voice_name:
self._send_command(set_synthesis_voice, name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]