From 62cda3ea2f079ea0830053de5e926858a70d3d71 Mon Sep 17 00:00:00 2001 From: un-pogaz <46523284+un-pogaz@users.noreply.github.com> Date: Sun, 16 Oct 2022 12:02:17 +0200 Subject: [PATCH] fix None args to empty --- src/calibre/utils/formatter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index 817b946b89..5d0820a623 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -896,8 +896,9 @@ class FormatterFuncsCaller(): if func_name: def call(*args, **kargs): - args = [str(a) for a in args] - kargs = {k:str(v if v else '') for k,v in kargs.items()} + args = [str('' if a is None else a) for a in args] + kargs = {k:str('' if v is None else v) for k,v in kargs.items()} + def raise_error(msg): raise ValueError(msg) @@ -1715,7 +1716,7 @@ 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 s in reversed(traceback.extract_tb(exc_info()[2])): + for s in reversed(stack): if s.filename == '': ss = s break