From 41c7b7f150826185d76038ea4f2b8140a29bf0ba Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 13 Oct 2022 20:05:34 +0530 Subject: [PATCH] Show the returned value in the error message --- src/calibre/utils/formatter.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index e10b0e7f96..4aba476da9 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -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):