After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 523642 - orca_prefs.py:_writePronunciation should not generate bad Python syntax
orca_prefs.py:_writePronunciation should not generate bad Python syntax
Status: RESOLVED FIXED
Product: orca
Classification: Applications
Component: general
unspecified
Other All
: High major
: 2.22.1
Assigned To: Rich Burridge
Orca Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-03-20 22:16 UTC by Willie Walker
Modified: 2008-03-26 22:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Revision #1. (673 bytes, patch)
2008-03-25 21:13 UTC, Rich Burridge
none Details | Review
Revision #2. (1.34 KB, patch)
2008-03-26 02:39 UTC, Rich Burridge
committed Details | Review

Description Willie Walker 2008-03-20 22:16:38 UTC
On the Orca user's list, we had a user who created a pronunciation for the " character.  This resulted in the following being output to ~/.orca/user-settings.py:

orca.pronunciation_dict.setPronunciation(""", "zitat")

orca_prefs.py:_writePronunciation is the offending function and it should do something different.  What, I'm not sure.  Maybe the repr function can help us?
Comment 1 Rich Burridge 2008-03-25 20:52:50 UTC
Unless I'm misunderstanding what you think I should be doing with repr
here, i don't think it's going to help us.

I tried the following diff:

Index: src/orca/orca_prefs.py
===================================================================
--- src/orca/orca_prefs.py	(revision 3752)
+++ src/orca/orca_prefs.py	(working copy)
@@ -586,8 +586,10 @@
         - value: the replacement string to use.
         """
 
+        print "XXX: word: ", word
+        print "XXX: value: ", value
         prefs.writelines("orca.pronunciation_dict.setPronunciation(\"" + \
-                 word + "\", \"" + value + "\")\n")
+                 repr(word) + "\", \"" + repr(value) + "\")\n")
 
     def _iteratePronunciations(self, prefs, treeModel):
         """Iterate over each of the entries in the tree model and write out

When I ran Orca and setup a new entry for '"' to be replaced by 'zitat'
I got the following output when I hit the OK button:

XXX: word:  "
XXX: value:  zitat

Traceback (most recent call last):
  • File "/usr/lib/python2.5/site-packages/orca/orca.py", line 833 in loadUserSettings
    reload(_userSettings)
  • File "/home/richb/.orca/user-settings.py", line 138
    orca.pronunciation_dict.setPronunciation("'"'", "'zitat'")

What had been put in the ~/.orca/user-settings.py file was:

...
orca.pronunciation_dict.setPronunciation("'"'", "'zitat'")
...


Comment 2 Rich Burridge 2008-03-25 21:13:49 UTC
Created attachment 108020 [details] [review]
Revision #1.

Didn't need to quote the repr() values. That automatically
gets done. I haven't surrounded this by a try: / except: clause
as it doesn't look like it's needed now.

Patch not committed yet. Please test.
Comment 3 Joanmarie Diggs (IRC: joanie) 2008-03-26 02:19:57 UTC
I've tried to commit various and sundry punctuation-based crimes against our pronunciation dictionary and haven't managed to break it yet, with your patch. :-)

Looks like a similar change will be needed in app_prefs.py though.
Comment 4 Rich Burridge 2008-03-26 02:39:09 UTC
Created attachment 108040 [details] [review]
Revision #2.

Thanks Joanie. Here's a version with a similar 
change to app_prefs.py as well.
Comment 5 Rich Burridge 2008-03-26 15:04:28 UTC
Latest patch committed to SVN trunk and gnome-2-22 branch.
Comment 6 Mike Pedersen 2008-03-26 21:16:20 UTC
This seems to work for me.  Hopefully Hermann will be testing it now that it is checked in.  
Comment 7 Joanmarie Diggs (IRC: joanie) 2008-03-26 21:55:07 UTC
I also did some more testing today, both of the regular and the app-specific pronunciation dictionaries.  Works for me as well.