Show the returned value in the error message

This commit is contained in:
Kovid Goyal 2022-10-13 20:05:34 +05:30
parent 1a2f46389b
commit 41c7b7f150
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1607,10 +1607,8 @@ class TemplateFormatter(string.Formatter):
ss = traceback.extract_tb(exc_info()[2])[-1]
raise ValueError(_('Error in function {0} on line {1} : {2} - {3}').format(
ss.name, ss.lineno, type(e).__name__, str(e)))
if not isinstance(rslt, str):
raise ValueError(_('The Python template does not return a string'))
raise ValueError(_('The Python template returned a non-string value: {!r}').format(rslt))
return rslt
def compile_python_template(self, template):