Commit fa4cb348 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

[py3] Fixed filesystem encoding handling

in the app directories template loader.
parent a4abe7ed
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -12,8 +12,10 @@ from django.template.base import TemplateDoesNotExist
from django.template.loader import BaseLoader
from django.utils._os import safe_join
from django.utils.importlib import import_module
from django.utils import six

# At compile time, cache the directories to search.
if not six.PY3:
    fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
app_template_dirs = []
for app in settings.INSTALLED_APPS:
@@ -23,7 +25,9 @@ for app in settings.INSTALLED_APPS:
        raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
    template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
    if os.path.isdir(template_dir):
        app_template_dirs.append(template_dir.decode(fs_encoding))
        if not six.PY3:
            template_dir = template_dir.decode(fs_encoding)
        app_template_dirs.append(template_dir)

# It won't change, so convert it to a tuple to save memory.
app_template_dirs = tuple(app_template_dirs)