TALInterpreter uses str() when it shouldn't, leads to unicode error

Bug #143310 reported by Bug Importer
0
Affects Status Importance Assigned to Milestone
Zope 2
Fix Released
Medium
Unassigned

Bug Description

When using an i18n:name directive on a tag that gets unicode content (with non-ascii chars) using tal:replace, the TAL machinery barfs because it tries to call str() on the content. Example:

> <span tal:replace="here/something_that_returns_nonascii_unicode" i18n:name="somename" />

The offending str() call seems to be in TAL/TALInterpreter.py, line 520:

> if not structure:
> value = cgi.escape(str(value))

Not entirely sure about my fix, but if I change this to the following it does work:

> if not structure:
> if type(value) not in [str, unicode]:
> value = str(value)
> value = cgi.escape(value)

Note that I don't have any PlacelessTranslationService or anything installed.

Tags: bug zope
Revision history for this message
Andres Herrera (andresh) wrote :

Hi, continues even with the problems in the newer versions?

Changed in zope2:
status: New → Incomplete
Revision history for this message
Hanno Schlichting (hannosch) wrote :

Zope2 uses the zope.tal implementation since 2.10 and uses unicode for page templates ever since.

Changed in zope2:
status: Incomplete → 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.