[PATCH 10 of 11] templatefilters: raise ProgrammingError if unencodable type passed to json()
Yuya Nishihara
yuya at tcha.org
Fri Mar 30 21:49:38 EDT 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1521359588 -32400
# Sun Mar 18 16:53:08 2018 +0900
# Node ID bf00dda4a053a9dbf7163e993a454dd9dc03cb1f
# Parent 68b69a593cf0865a1485d10a87c58f1c3254fb76
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):
More information about the Mercurial-devel
mailing list