This commit is contained in:
Kovid Goyal 2022-10-29 19:05:08 +05:30
commit 4918c061b6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1576,9 +1576,10 @@ class TemplateFormatter(string.Formatter):
self.funcs = formatter_functions().get_functions() self.funcs = formatter_functions().get_functions()
self._interpreters = [] self._interpreters = []
self._template_parser = None self._template_parser = None
self._caller = FormatterFuncsCaller(self)
self.recursion_stack = [] self.recursion_stack = []
self.recursion_level = -1 self.recursion_level = -1
self._caller = None
self.python_context_object = None
def _do_format(self, val, fmt): def _do_format(self, val, fmt):
if not fmt or not val: if not fmt or not val:
@ -1840,7 +1841,9 @@ class TemplateFormatter(string.Formatter):
self.book, self.book,
self.global_vars, self.global_vars,
self.funcs, self.funcs,
self.locals)) self.locals,
self._caller,
self.python_context_object))
else: else:
return None return None
@ -1854,7 +1857,9 @@ class TemplateFormatter(string.Formatter):
self.book, self.book,
self.global_vars, self.global_vars,
self.funcs, self.funcs,
self.locals) = state self.locals,
self._caller,
self.python_context_object) = state
# Allocate an interpreter if the formatter encounters a GPM or TPM template. # Allocate an interpreter if the formatter encounters a GPM or TPM template.
# We need to allocate additional interpreters if there is composite recursion # We need to allocate additional interpreters if there is composite recursion
@ -1883,6 +1888,7 @@ class TemplateFormatter(string.Formatter):
python_context_object=None): python_context_object=None):
state = self.save_state() state = self.save_state()
try: try:
self._caller = FormatterFuncsCaller(self)
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
@ -1911,6 +1917,7 @@ class TemplateFormatter(string.Formatter):
# call. Recursive calls will use the same dict. # call. Recursive calls will use the same dict.
self.composite_values = {} self.composite_values = {}
try: try:
self._caller = FormatterFuncsCaller(self)
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