# HG changeset patch
# User Yuki KODAMA <endflow....@gmail.com>
# Date 1254068037 -32400
# Node ID 3af7e75877aaf8ac1373463628b3851d159e2588
# Parent  30246dc350e4890214b2e6b3b1f6d8f97edfcfe7
gdialog: catch ValueError occurred in CustomPrompt

In case of the choice string doesn't have '&' char, 'str.index()'
raises ValueError.  In general, choice string was wrapped with
gettext '_' function, so translated string doesn't always have
'&' char in some languages.

diff --git a/tortoisehg/hgtk/gdialog.py b/tortoisehg/hgtk/gdialog.py
--- a/tortoisehg/hgtk/gdialog.py
+++ b/tortoisehg/hgtk/gdialog.py
@@ -58,10 +58,13 @@
         accel_group = gtk.AccelGroup()
         self.add_accel_group(accel_group)
         for i, s in enumerate(choices):
-            char = s[s.index('&')+1].lower()
             button = self.add_button(s.replace('&', '_'), i)
-            button.add_accelerator('clicked', accel_group, ord(char), 0,
-                    gtk.ACCEL_VISIBLE)
+            try:
+                char = s[s.index('&')+1].lower()
+                button.add_accelerator('clicked', accel_group, ord(char), 0,
+                        gtk.ACCEL_VISIBLE)
+            except ValueError:
+                pass
         if default:
             self.set_default_response(default)
         self.esc = esc

Attachment: thg-kuy_rev4233.patch
Description: Binary data

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Tortoisehg-develop mailing list
Tortoisehg-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop

Reply via email to