mercurial/templatefilters.py
changeset 37229 05db42732fce
parent 37227 9bcf096a2da2
child 37230 63144f33c8bb
--- a/mercurial/templatefilters.py	Sun Mar 18 17:02:39 2018 +0900
+++ b/mercurial/templatefilters.py	Sun Mar 18 16:47:44 2018 +0900
@@ -11,6 +11,7 @@
 import re
 import time
 
+from .i18n import _
 from . import (
     encoding,
     error,
@@ -101,7 +102,10 @@
 @templatefilter('count')
 def count(i):
     """List or text. Returns the length as an integer."""
-    return len(i)
+    try:
+        return len(i)
+    except TypeError:
+        raise error.ParseError(_('not countable'))
 
 @templatefilter('dirname', intype=bytes)
 def dirname(path):