mercurial/templater.py
branchstable
changeset 24886 10a13da8840d
parent 24601 d80819f67d59
child 24903 09124cce913f
--- a/mercurial/templater.py	Wed Apr 29 21:14:59 2015 -0400
+++ b/mercurial/templater.py	Thu Apr 30 12:33:36 2015 -0700
@@ -539,7 +539,12 @@
         raise error.ParseError(_("word expects two or three arguments, got %d")
                                % len(args))
 
-    num = int(stringify(args[0][0](context, mapping, args[0][1])))
+    try:
+        num = int(stringify(args[0][0](context, mapping, args[0][1])))
+    except ValueError:
+        # i18n: "word" is a keyword
+        raise error.ParseError(
+                _("Use strings like '3' for numbers passed to word function"))
     text = stringify(args[1][0](context, mapping, args[1][1]))
     if len(args) == 3:
         splitter = stringify(args[2][0](context, mapping, args[2][1]))