Mercurial > hg > mercurial-source
diff mercurial/templatefilters.py @ 38015:05db42732fce
templatefilters: handle TypeError by count()
Prepares for removing the weird exception catcher from runfilter().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 18 Mar 2018 16:47:44 +0900 |
parents | 9bcf096a2da2 |
children | 63144f33c8bb |
line wrap: on
line diff
--- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -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):