# HG changeset patch # User Yuya Nishihara # Date 2018-03-18 07:53:08 # Node ID 63144f33c8bb7171059e11eb5d69a1e910cdebbc # Parent 05db42732fce64c50d30aed9e0d16bdab0827ed7 templatefilters: raise ProgrammingError if unencodable type passed to json() This shouldn't happen for any template data types (though I know it does because of some templater bugs.) Let's clarify it is a bug. diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -263,8 +263,7 @@ def json(obj, paranoid=True): elif util.safehasattr(obj, '__iter__'): out = [json(i, paranoid) for i in obj] return '[' + ', '.join(out) + ']' - else: - raise TypeError('cannot encode type %s' % obj.__class__.__name__) + raise error.ProgrammingError('cannot encode %r' % obj) @templatefilter('lower', intype=bytes) def lower(text):