Skip to content

Commit

Permalink
- be more explicit when passing the encoding parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Apr 25, 2019
1 parent ad2915f commit 44a1c60
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/DocumentTemplate/DT_In.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def renderwb(self, md):

if not sequence:
if self.elses:
return render_blocks(self.elses, md, self.encoding)
return render_blocks(self.elses, md, encoding=self.encoding)
return ''

if isinstance(sequence, str):
Expand Down Expand Up @@ -650,7 +650,7 @@ def renderwb(self, md):
if index == first:
pkw['sequence-start'] = 0

result = join_unicode(result, self.encoding)
result = join_unicode(result, encoding=self.encoding)

finally:
if cache:
Expand All @@ -672,7 +672,7 @@ def renderwob(self, md):

if not sequence:
if self.elses:
return render_blocks(self.elses, md, self.encoding)
return render_blocks(self.elses, md, encoding=self.encoding)
return ''

if isinstance(sequence, str):
Expand Down Expand Up @@ -762,7 +762,7 @@ def renderwob(self, md):
if index == 0:
pkw['sequence-start'] = 0

result = join_unicode(result, self.encoding)
result = join_unicode(result, encoding=self.encoding)

finally:
if cache:
Expand Down
2 changes: 1 addition & 1 deletion src/DocumentTemplate/DT_Let.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def render(self, md):
d[name] = md[expr]
else:
d[name] = expr(md)
return render_blocks(self.section, md, self.encoding)
return render_blocks(self.section, md, encoding=self.encoding)
finally:
md._pop(1)

Expand Down
2 changes: 1 addition & 1 deletion src/DocumentTemplate/DT_Raise.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def render(self, md):
t = InvalidErrorTypeExpression

try:
v = render_blocks(self.section, md, self.encoding)
v = render_blocks(self.section, md, encoding=self.encoding)
except Exception:
v = 'Invalid Error Value'

Expand Down
3 changes: 2 additions & 1 deletion src/DocumentTemplate/DT_String.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,8 @@ def __call__(self, client=None, mapping={}, **kw):
value = self.ZDocumentTemplate_beforeRender(md, _marker)
if value is _marker:
try:
result = render_blocks(self._v_blocks, md, self.encoding)
result = render_blocks(self._v_blocks, md,
encoding=self.encoding)
except DTReturn as v:
result = v.v
self.ZDocumentTemplate_afterRender(md, result)
Expand Down
10 changes: 5 additions & 5 deletions src/DocumentTemplate/DT_Try.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def render_try_except(self, md):

# first we try to render the first block
try:
result = render_blocks(self.section, md, self.encoding)
result = render_blocks(self.section, md, encoding=self.encoding)
except DTReturn:
raise
except Exception:
Expand All @@ -171,7 +171,7 @@ def render_try_except(self, md):
ns = namespace(md, error_type=errname, error_value=v,
error_tb=error_tb)[0]
md._push(InstanceDict(ns, md))
return render_blocks(handler, md, self.encoding)
return render_blocks(handler, md, encoding=self.encoding)
finally:
md._pop(1)

Expand All @@ -181,17 +181,17 @@ def render_try_except(self, md):
return result
else:
return result + render_blocks(self.elseBlock, md,
self.encoding)
encoding=self.encoding)

def render_try_finally(self, md):
result = ''
# first try to render the first block
try:
result = render_blocks(self.section, md, self.encoding)
result = render_blocks(self.section, md, encoding=self.encoding)
# Then handle finally block
finally:
result = result + render_blocks(self.finallyBlock, md,
self.encoding)
encoding=self.encoding)
return result

def find_handler(self, exception):
Expand Down
2 changes: 1 addition & 1 deletion src/DocumentTemplate/DT_With.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def render(self, md):

md._push(v)
try:
return render_blocks(self.section, md, self.encoding)
return render_blocks(self.section, md, encoding=self.encoding)
finally:
md._pop(1)

Expand Down

0 comments on commit 44a1c60

Please sign in to comment.