template.py does not understand unicode literals

Bug #120644 reported by Anand Chitipothu on 2007-06-16
Affects Status Importance Assigned to Milestone
Anand Chitipothu

Bug Description

The following test fails because template.py does not understand unicode literals.

        lambda: t(u'$def with (f)\n$f("x")')(lambda x:x), 'x\n',

And here is the fix.

     def h_literal(self, i):
         item = i[THING]
- if isinstance(item, str) and item[0] in ['"', "'"]:
+ if isinstance(item, (str, unicode)) and item[0] in ['"', "'"]:
             item = item[1:-1]
         elif isinstance(item, (float, int)):

Adam Atlas (adam-atlas) wrote :

Actually, instead of `(str, unicode)`, you can just use `basestring`. That's what it's for.

And it might be a few milliseconds faster. :)

Changed in webpy:
status: New → Fix Committed
Changed in webpy:
assignee: nobody → anandology
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers