mirror of
https://github.com/django/django.git
synced 2024-12-26 11:06:07 +00:00
[py3] Fixed filesystem encoding handling
in the app directories template loader.
This commit is contained in:
parent
a4abe7ed56
commit
fa4cb34817
@ -12,9 +12,11 @@ from django.template.base import TemplateDoesNotExist
|
|||||||
from django.template.loader import BaseLoader
|
from django.template.loader import BaseLoader
|
||||||
from django.utils._os import safe_join
|
from django.utils._os import safe_join
|
||||||
from django.utils.importlib import import_module
|
from django.utils.importlib import import_module
|
||||||
|
from django.utils import six
|
||||||
|
|
||||||
# At compile time, cache the directories to search.
|
# At compile time, cache the directories to search.
|
||||||
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
|
if not six.PY3:
|
||||||
|
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
|
||||||
app_template_dirs = []
|
app_template_dirs = []
|
||||||
for app in settings.INSTALLED_APPS:
|
for app in settings.INSTALLED_APPS:
|
||||||
try:
|
try:
|
||||||
@ -23,7 +25,9 @@ for app in settings.INSTALLED_APPS:
|
|||||||
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
|
raise ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0]))
|
||||||
template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
|
template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
|
||||||
if os.path.isdir(template_dir):
|
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.
|
# It won't change, so convert it to a tuple to save memory.
|
||||||
app_template_dirs = tuple(app_template_dirs)
|
app_template_dirs = tuple(app_template_dirs)
|
||||||
|
Loading…
Reference in New Issue
Block a user