diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index 1e8925c45d..13e678b83b 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -1647,8 +1647,9 @@ class TemplateFormatter(string.Formatter): if getattr(e, 'is_internal', False): # Exception raised by FormatterFuncsCaller # get the line inside the current template instead of the FormatterFuncsCaller - for ss in reversed(traceback.extract_tb(exc_info()[2])): - if ss.filename == '': + for s in reversed(traceback.extract_tb(exc_info()[2])): + if s.filename == '': + ss = s break raise ValueError(_('Error in function {0} on line {1} : {2} - {3}').format(