Permalink
Browse files

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

IronPython fails to correctly reference unicode strings containing non-ASCII characters.  This covers issue #146.
  • Loading branch information...
1 parent 21a2010 commit b9ced43fca2cb3d463feab1edaae5e3bb3d978e4 @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 sys.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 b9ced43

Please sign in to comment.