UnicodeDecodeError when accented chars are present in test result tables

Bug #575415 reported by LeoRochael
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Zelenium
Fix Released
Undecided
Tres Seaver

Bug Description

If a zuite contains accented chars, and those get transplanted into test results, the ZuiteResults object cannot render to html properly resulting in an UnicodeDecodeError:

Traceback (most recent call last):
  [...]
  File "/home/leo/opt/zelenium/eggs/Zope2-2.12.5-py2.6-linux-x86_64.egg/Shared/DC/Scripts/Bindings.py", line 324, in __call__
    return self._bindAndExec(args, kw, None)
  File "/home/leo/opt/zelenium/eggs/Zope2-2.12.5-py2.6-linux-x86_64.egg/Shared/DC/Scripts/Bindings.py", line 361, in _bindAndExec
    return self._exec(bound_data, args, kw)
  File "/home/leo/opt/zelenium/eggs/Zope2-2.12.5-py2.6-linux-x86_64.egg/Products/PageTemplates/PageTemplateFile.py", line 130, in _exec
    return self.pt_render(extra_context=bound_names)
  File "/home/leo/opt/zelenium/eggs/Zope2-2.12.5-py2.6-linux-x86_64.egg/Products/PageTemplates/PageTemplate.py", line 80, in pt_render
    showtal=showtal)
  File "/home/leo/opt/zelenium/eggs/zope.pagetemplate-3.5.0-py2.6.egg/zope/pagetemplate/pagetemplate.py", line 115, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations)()
  File "/home/leo/opt/zelenium/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 271, in __call__
    self.interpret(self.program)
  [...]
  File "/home/leo/opt/zelenium/eggs/zope.tal-3.5.2-py2.6.egg/zope/tal/talinterpreter.py", line 742, in do_insertStructure_tal
    structure = self.engine.evaluateStructure(expr)
  File "/home/leo/opt/zelenium/eggs/Zope2-2.12.5-py2.6-linux-x86_64.egg/Products/PageTemplates/Expressions.py", line 221, in evaluateStructure
    return self._handleText(text, expr)
  File "/home/leo/opt/zelenium/eggs/Zope2-2.12.5-py2.6-linux-x86_64.egg/Products/PageTemplates/Expressions.py", line 266, in _handleText
    return unicode(text)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 271: ordinal not in range(128)

This is caused by the TALES engine trying to directly convert the OFS.Image.File object that represents a test table into unicode. Since File objects can never be unicode by definition, this is guaranteed to bork if there are accented chars in it.

The attached patch contains a test and a one-line work-around. Took me a minute to write the work-around, and the whole day for the test...

The work-around converts the OFS.Image.File to string first, giving the TALES unicode-conflict-resolver a chance to do its magic.

Revision history for this message
LeoRochael (leorochael) wrote :
Tres Seaver (tseaver)
Changed in zelenium:
status: New → Fix Committed
assignee: nobody → Tres Seaver (tseaver)
Revision history for this message
Tres Seaver (tseaver) wrote :

Fix released with version 1.0.2:

 http://pypi.python.org/pypi/Products.Zelenium/1.0.2

Changed in zelenium:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.