Support non-ascii template filenames.

Fixes #1502.
This commit is contained in:
Ben Darnell 2015-09-27 18:29:54 -04:00
parent 9ebfc39754
commit fc77d7fe13
2 changed files with 5 additions and 1 deletions

View File

@ -271,7 +271,7 @@ class Template(object):
.. versionchanged:: 4.3
Added ``whitespace`` parameter; deprecated ``compress_whitespace``.
"""
self.name = name
self.name = escape.native_str(name)
if compress_whitespace is not _UNSET:
# Convert deprecated compress_whitespace (bool) to whitespace (str).

View File

@ -173,6 +173,10 @@ try{% set y = 1/x %}
template = Template('{{ 1 / 2 }}')
self.assertEqual(template.generate(), '0')
def test_non_ascii_name(self):
loader = DictLoader({u("t\u00e9st.html"): "hello"})
self.assertEqual(loader.load(u("t\u00e9st.html")).generate(), b"hello")
class StackTraceTest(unittest.TestCase):
def test_error_line_number_expression(self):