diff --git a/pyramid/static.py b/pyramid/static.py index 71534d09cb..d3075fec0e 100644 --- a/pyramid/static.py +++ b/pyramid/static.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import os from os.path import normcase, normpath, join, getmtime, getsize, isdir, exists from pkg_resources import resource_exists, resource_filename, resource_isdir @@ -178,4 +179,6 @@ def _secure_path(path_tuple): return None if any([contains_slash(item) for item in path_tuple]): return None - return '/'.join([x.encode('utf-8') for x in path_tuple]) + encoded = u'/'.join(path_tuple) # will be unicode + return encoded + diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index 753a55d366..1cbebd4c19 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import os import unittest @@ -72,20 +74,22 @@ def test_basic(self): def test_hidden(self): res = self.testapp.get('/static/.hiddenfile', status=200) - self._assertBody(res.body, os.path.join(here, - 'fixtures/static/.hiddenfile')) + self._assertBody( + res.body, + os.path.join(here, 'fixtures/static/.hiddenfile') + ) def test_highchars_in_pathelement(self): - res = self.testapp.get('/static/h\xc3\xa9h\xc3\xa9/index.html', - status=200) - self._assertBody(res.body, os.path.join( - here, 'fixtures/static/h\xc3\xa9h\xc3\xa9/index.html')) + res = self.testapp.get('/static/héhé/index.html', status=200) + self._assertBody( + res.body, os.path.join(here, u'fixtures/static/héhé/index.html') + ) def test_highchars_in_filename(self): - res = self.testapp.get('/static/h\xc3\xa9h\xc3\xa9.html', - status=200) - self._assertBody(res.body, os.path.join( - here, 'fixtures/static/h\xc3\xa9h\xc3\xa9.html')) + res = self.testapp.get('/static/héhé.html', status=200) + self._assertBody( + res.body, os.path.join(here, u'fixtures/static/héhé.html') + ) def test_not_modified(self): self.testapp.extra_environ = {