Loading django/core/management/commands/makemessages.py +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ class TranslatableFile(object): work_file = orig_file is_templatized = file_ext in command.extensions if is_templatized: with io.open(orig_file, 'r', encoding=settings.FILE_CHARSET) as fp: with io.open(orig_file, encoding=settings.FILE_CHARSET) as fp: src_data = fp.read() content = templatize(src_data, orig_file[2:]) work_file = os.path.join(self.dirpath, '%s.py' % self.file) Loading django/core/management/sql.py +2 −2 Original line number Diff line number Diff line from __future__ import unicode_literals import codecs import io import os import re import warnings Loading Loading @@ -234,7 +234,7 @@ def custom_sql_for_model(model, style, connection): sql_files.append(os.path.join(app_dir, "%s.sql" % opts.model_name)) for sql_file in sql_files: if os.path.exists(sql_file): with codecs.open(sql_file, 'r', encoding=settings.FILE_CHARSET) as fp: with io.open(sql_file, encoding=settings.FILE_CHARSET) as fp: output.extend(connection.ops.prepare_sql_script(fp.read(), _allow_fallback=True)) return output Loading django/template/loaders/app_directories.py +3 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ Wrapper for loading templates from "templates" directories in INSTALLED_APPS packages. """ import io import os import sys Loading Loading @@ -56,8 +57,8 @@ class Loader(BaseLoader): def load_template_source(self, template_name, template_dirs=None): for filepath in self.get_template_sources(template_name, template_dirs): try: with open(filepath, 'rb') as fp: return (fp.read().decode(settings.FILE_CHARSET), filepath) with io.open(filepath, encoding=settings.FILE_CHARSET) as fp: return fp.read(), filepath except IOError: pass raise TemplateDoesNotExist(template_name) django/template/loaders/filesystem.py +4 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ Wrapper for loading templates from the filesystem. """ import io from django.conf import settings from django.core.exceptions import SuspiciousFileOperation from django.template.base import TemplateDoesNotExist Loading Loading @@ -32,8 +34,8 @@ class Loader(BaseLoader): tried = [] for filepath in self.get_template_sources(template_name, template_dirs): try: with open(filepath, 'rb') as fp: return (fp.read().decode(settings.FILE_CHARSET), filepath) with io.open(filepath, encoding=settings.FILE_CHARSET) as fp: return fp.read(), filepath except IOError: tried.append(filepath) if tried: Loading Loading
django/core/management/commands/makemessages.py +1 −1 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ class TranslatableFile(object): work_file = orig_file is_templatized = file_ext in command.extensions if is_templatized: with io.open(orig_file, 'r', encoding=settings.FILE_CHARSET) as fp: with io.open(orig_file, encoding=settings.FILE_CHARSET) as fp: src_data = fp.read() content = templatize(src_data, orig_file[2:]) work_file = os.path.join(self.dirpath, '%s.py' % self.file) Loading
django/core/management/sql.py +2 −2 Original line number Diff line number Diff line from __future__ import unicode_literals import codecs import io import os import re import warnings Loading Loading @@ -234,7 +234,7 @@ def custom_sql_for_model(model, style, connection): sql_files.append(os.path.join(app_dir, "%s.sql" % opts.model_name)) for sql_file in sql_files: if os.path.exists(sql_file): with codecs.open(sql_file, 'r', encoding=settings.FILE_CHARSET) as fp: with io.open(sql_file, encoding=settings.FILE_CHARSET) as fp: output.extend(connection.ops.prepare_sql_script(fp.read(), _allow_fallback=True)) return output Loading
django/template/loaders/app_directories.py +3 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ Wrapper for loading templates from "templates" directories in INSTALLED_APPS packages. """ import io import os import sys Loading Loading @@ -56,8 +57,8 @@ class Loader(BaseLoader): def load_template_source(self, template_name, template_dirs=None): for filepath in self.get_template_sources(template_name, template_dirs): try: with open(filepath, 'rb') as fp: return (fp.read().decode(settings.FILE_CHARSET), filepath) with io.open(filepath, encoding=settings.FILE_CHARSET) as fp: return fp.read(), filepath except IOError: pass raise TemplateDoesNotExist(template_name)
django/template/loaders/filesystem.py +4 −2 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ Wrapper for loading templates from the filesystem. """ import io from django.conf import settings from django.core.exceptions import SuspiciousFileOperation from django.template.base import TemplateDoesNotExist Loading Loading @@ -32,8 +34,8 @@ class Loader(BaseLoader): tried = [] for filepath in self.get_template_sources(template_name, template_dirs): try: with open(filepath, 'rb') as fp: return (fp.read().decode(settings.FILE_CHARSET), filepath) with io.open(filepath, encoding=settings.FILE_CHARSET) as fp: return fp.read(), filepath except IOError: tried.append(filepath) if tried: Loading