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.
--- a/mercurial/templatefilters.py Sun Mar 18 16:47:44 2018 +0900
+++ b/mercurial/templatefilters.py Sun Mar 18 16:53:08 2018 +0900
@@ -263,8 +263,7 @@
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):