From fc77d7fe137721dd81fdf6ce0f1ae384c4fe8092 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sun, 27 Sep 2015 18:29:54 -0400 Subject: [PATCH] Support non-ascii template filenames. Fixes #1502. --- tornado/template.py | 2 +- tornado/test/template_test.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tornado/template.py b/tornado/template.py index 959b191d..fa588991 100644 --- a/tornado/template.py +++ b/tornado/template.py @@ -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). diff --git a/tornado/test/template_test.py b/tornado/test/template_test.py index 77f42e2f..0c8eb51c 100644 --- a/tornado/test/template_test.py +++ b/tornado/test/template_test.py @@ -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):