GNOME Bugzilla – Bug 523642
orca_prefs.py:_writePronunciation should not generate bad Python syntax
Last modified: 2008-03-26 22:28:31 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?
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):
+ Trace 193322
reload(_userSettings)
orca.pronunciation_dict.setPronunciation("'"'", "'zitat'")
What had been put in the ~/.orca/user-settings.py file was: ... orca.pronunciation_dict.setPronunciation("'"'", "'zitat'") ...
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.
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.
Created attachment 108040 [details] [review] Revision #2. Thanks Joanie. Here's a version with a similar change to app_prefs.py as well.
Latest patch committed to SVN trunk and gnome-2-22 branch.
This seems to work for me. Hopefully Hermann will be testing it now that it is checked in.
I also did some more testing today, both of the regular and the app-specific pronunciation dictionaries. Works for me as well.