Permalink
Browse files

Update jinja2/runtime.py to handle IronPython unicode strings issue.

IronPython fails to correctly reference unicode strings containing non-ASCII characters.

This covers [issue #146][1]

[1]:  #146
  • Loading branch information...
1 parent 21a2010 commit 9e333b7436bdf384d003e8e7cc7855a4286639e6 @WillSams WillSams committed Oct 12, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 jinja2/runtime.py
View
@@ -15,6 +15,7 @@
from jinja2.exceptions import UndefinedError, TemplateRuntimeError, \
TemplateNotFound
+import os
# these variables are exported to the template runtime
__all__ = ['LoopContext', 'TemplateReference', 'Macro', 'Markup',
@@ -25,7 +26,11 @@
#: the name of the function that is used to convert something into
#: a string. 2to3 will adopt that automatically and the generated
#: code can take advantage of it.
-to_string = unicode
+to_string = None
+if not 'IronPython' in py_version:
+ to_string = unicode
+else:
+ to_string = to_string = lambda x: unicode(x)
#: the identity function. Useful for certain things in the environment
identity = lambda x: x

0 comments on commit 9e333b7

Please sign in to comment.