Skip to content

Commit

Permalink
- fix missing encoding arguments in constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake committed Apr 22, 2019
1 parent 0f10935 commit c2b0754
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/DocumentTemplate/DT_If.py
Expand Up @@ -137,7 +137,8 @@ class Unless(object):
name = 'unless'
blockContinuations = ()

def __init__(self, blocks):
def __init__(self, blocks, encoding=None):
self.encoding = encoding
tname, args, section = blocks[0]
args = parse_params(args, name='', expr='')
name, expr = name_param(args, 'unless', 1)
Expand Down
3 changes: 2 additions & 1 deletion src/DocumentTemplate/DT_Try.py
Expand Up @@ -90,11 +90,12 @@ class Try(object):
finallyBlock = None
elseBlock = None

def __init__(self, blocks):
def __init__(self, blocks, encoding=None):
tname, args, section = blocks[0]

self.args = parse_params(args)
self.section = section.blocks
self.encoding = encoding

# Find out if this is a try..finally type
if len(blocks) == 2 and blocks[1][0] == 'finally':
Expand Down
4 changes: 3 additions & 1 deletion src/DocumentTemplate/tests/testDTMLUnicode.py
Expand Up @@ -42,7 +42,9 @@ def make(*args):
doc_class = property(_get_doc_class,)

def _recode(self, string):
return string.decode("utf-8").encode(self.recode_to)
if isinstance(string, six.binary_type):
string = string.decode('UTF-8')
return string.encode(self.recode_to)

def testAA(self):
html = self.doc_class('<dtml-var a><dtml-var b>')
Expand Down

0 comments on commit c2b0754

Please sign in to comment.