summaryrefslogtreecommitdiff
path: root/src/mailman/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman/app')
-rw-r--r--src/mailman/app/templates.py2
-rw-r--r--src/mailman/app/tests/test_templates.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/src/mailman/app/templates.py b/src/mailman/app/templates.py
index 707e7c256..f0b4222cb 100644
--- a/src/mailman/app/templates.py
+++ b/src/mailman/app/templates.py
@@ -103,4 +103,4 @@ class TemplateLoader:
def get(self, uri):
"""See `ITemplateLoader`."""
with closing(urllib2.urlopen(uri)) as fp:
- return fp.read()
+ return fp.read().decode('utf-8')
diff --git a/src/mailman/app/tests/test_templates.py b/src/mailman/app/tests/test_templates.py
index 77a0eb381..59c9a05df 100644
--- a/src/mailman/app/tests/test_templates.py
+++ b/src/mailman/app/tests/test_templates.py
@@ -126,3 +126,14 @@ class TestTemplateLoader(unittest.TestCase):
with self.assertRaises(urllib2.URLError) as cm:
self._loader.get('mailman:///missing@example.com/en/foo/demo.txt')
self.assertEqual(cm.exception.reason, 'No such file')
+
+ def test_non_ascii(self):
+ # mailman://demo.txt with non-ascii content.
+ test_text = b'\xe4\xb8\xad'
+ path = os.path.join(self.var_dir, 'templates', 'site', 'it')
+ os.makedirs(path)
+ with open(os.path.join(path, 'demo.txt'), 'w') as fp:
+ print(test_text, end='', file=fp)
+ content = self._loader.get('mailman:///it/demo.txt')
+ self.assertTrue(isinstance(content, unicode))
+ self.assertEqual(content, test_text.decode('utf-8'))