mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix #1909217 [Error saving books on disk](https://bugs.launchpad.net/calibre/+bug/1909217)
This commit is contained in:
parent
2ccfa5140e
commit
27f11a66ea
@ -851,22 +851,22 @@ class TemplateFormatter(string.Formatter):
|
|||||||
|
|
||||||
# ######### a formatter that throws exceptions ############
|
# ######### a formatter that throws exceptions ############
|
||||||
|
|
||||||
def unsafe_format(self, fmt, kwargs, book, strip_results=True):
|
def unsafe_format(self, fmt, kwargs, book, strip_results=True, global_vars=None):
|
||||||
self.strip_results = strip_results
|
self.strip_results = strip_results
|
||||||
self.column_name = self.template_cache = None
|
self.column_name = self.template_cache = None
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
self.book = book
|
self.book = book
|
||||||
self.composite_values = {}
|
self.composite_values = {}
|
||||||
self.locals = {}
|
self.locals = {}
|
||||||
self.global_vars = {}
|
self.global_vars = global_vars if isinstance(global_vars, dict) else {}
|
||||||
return self.evaluate(fmt, [], kwargs)
|
return self.evaluate(fmt, [], kwargs, self.global_vars)
|
||||||
|
|
||||||
# ######### a formatter guaranteed not to throw an exception ############
|
# ######### a formatter guaranteed not to throw an exception ############
|
||||||
|
|
||||||
def safe_format(self, fmt, kwargs, error_value, book,
|
def safe_format(self, fmt, kwargs, error_value, book,
|
||||||
column_name=None, template_cache=None,
|
column_name=None, template_cache=None,
|
||||||
strip_results=True, template_functions=None,
|
strip_results=True, template_functions=None,
|
||||||
global_vars={}):
|
global_vars=None):
|
||||||
self.strip_results = strip_results
|
self.strip_results = strip_results
|
||||||
self.column_name = column_name
|
self.column_name = column_name
|
||||||
self.template_cache = template_cache
|
self.template_cache = template_cache
|
||||||
@ -880,7 +880,7 @@ class TemplateFormatter(string.Formatter):
|
|||||||
self.composite_values = {}
|
self.composite_values = {}
|
||||||
self.locals = {}
|
self.locals = {}
|
||||||
try:
|
try:
|
||||||
ans = self.evaluate(fmt, [], kwargs, global_vars)
|
ans = self.evaluate(fmt, [], kwargs, self.global_vars)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if DEBUG: # and getattr(e, 'is_locking_error', False):
|
if DEBUG: # and getattr(e, 'is_locking_error', False):
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user