Skip to content

Commit

Permalink
Fix unicode decode error in weird cases
Browse files Browse the repository at this point in the history
- Prevent assigning label to term.value before overwriting it if term is an ITitledTokenizedTerm
- Prevent unicode decode error when we have a ITitledTokenizedTerm term and term.value is nor string nor unicode and __str__ returns non ascii string (eg: Archetype ATFile)
  • Loading branch information
jribouxquadra committed Jul 4, 2013
1 parent 2713e3b commit def42a8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/z3c/form/browser/radio.py
Expand Up @@ -47,10 +47,11 @@ def update(self):
for count, term in enumerate(self.terms):
checked = self.isChecked(term)
id = '%s-%i' % (self.id, count)
label = util.toUnicode(term.value)
if zope.schema.interfaces.ITitledTokenizedTerm.providedBy(term):
label = translate(term.title, context=self.request,
default=term.title)
else:
label = util.toUnicode(term.value)
self.items.append(
{'id':id, 'name':self.name, 'value':term.token,
'label':label, 'checked':checked})
Expand Down

0 comments on commit def42a8

Please sign in to comment.