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 def42a8 commit 910c83f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/z3c/form/browser/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,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 + ':list', 'value':term.token,
'label':label, 'checked':checked})
Expand Down

0 comments on commit 910c83f

Please sign in to comment.