Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 9e333b7436bdf384d003e8e7cc7855a4286639e6 1 parent 21a2010
@WillSams WillSams authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 jinja2/runtime.py
View
7 jinja2/runtime.py
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.