#2996 closed defect (fixed)
[possible patch] template.Nodelist.render and non-ascii data
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | major | Keywords: | unicode-branch |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
template.Nodelist.render raised an exception in
return ''.join(bits)
UnicodeDecodeError : 'ascii' codec can't decode byte 0xd1 in position
3128: ordinal not in range(128)
The problem was that the content it tried to join had UTF-8 characters.
The *temporary* patch that worked for me was to write the render method
as follows:
def render(self, context): bits = [] for node in self: if isinstance(node, Node): bits.append(self.render_node(node, context).decode(settings.DEFAULT_CHARSET)) else: bits.append(node.decode(settings.DEFAULT_CHARSET)) return ''.join(bits).encode(settings.DEFAULT_CHARSET)
However, I suppose the bug can be deeper than this and should be fixed
somewhere else.
regards,
Max
Change History (4)
comment:1 by , 18 years ago
Keywords: | unicode-branch added |
---|
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
This was fixed in the unicode-branch, in [4971]. I will close the ticket once the branch is merged into trunk.