Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templatefilters.py @ 14944:e2c413bde8a5
globally: use safehasattr(x, '__iter__') instead of hasattr(x, '__iter__')
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Mon, 25 Jul 2011 15:30:19 -0500 |
parents | 1f46be4689ed |
children | 376091a4ad23 |
line wrap: on
line diff
--- a/mercurial/templatefilters.py Mon Jul 25 16:24:37 2011 -0500 +++ b/mercurial/templatefilters.py Mon Jul 25 15:30:19 2011 -0500 @@ -194,7 +194,7 @@ s = '%s: %s' % (json(k), json(v)) out.append(s) return '{' + ', '.join(out) + '}' - elif hasattr(obj, '__iter__'): + elif util.safehasattr(obj, '__iter__'): out = [] for i in obj: out.append(json(i)) @@ -279,7 +279,7 @@ """:stringify: Any type. Turns the value into text by converting values into text and concatenating them. """ - if hasattr(thing, '__iter__') and not isinstance(thing, str): + if util.safehasattr(thing, '__iter__') and not isinstance(thing, str): return "".join([stringify(t) for t in thing if t is not None]) return str(thing)