From: Ben Darnell Date: Sun, 27 Sep 2015 22:29:54 +0000 (-0400) Subject: Support non-ascii template filenames. X-Git-Tag: v4.3.0b1~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc77d7fe137721dd81fdf6ce0f1ae384c4fe8092;p=thirdparty%2Ftornado.git Support non-ascii template filenames. Fixes #1502. --- diff --git a/tornado/template.py b/tornado/template.py index 959b191d6..fa588991e 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 77f42e2f0..0c8eb51cb 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):