Kaydet (Commit) ac8d0a48 authored tarafından Marc Tamlyn's avatar Marc Tamlyn

Remove unneded open(.., 'U') when on python 3.

Universal newlines is enabled by default on py3, and the usage of 'U' is
deprecated in py3.4.
üst 660b7e70
...@@ -13,6 +13,7 @@ from django.core.management.utils import (handle_extensions, find_command, ...@@ -13,6 +13,7 @@ from django.core.management.utils import (handle_extensions, find_command,
popen_wrapper) popen_wrapper)
from django.utils.encoding import force_str from django.utils.encoding import force_str
from django.utils.functional import total_ordering from django.utils.functional import total_ordering
from django.utils import six
from django.utils.text import get_text_list from django.utils.text import get_text_list
from django.utils.jslex import prepare_js_for_gettext from django.utils.jslex import prepare_js_for_gettext
...@@ -93,7 +94,7 @@ class TranslatableFile(object): ...@@ -93,7 +94,7 @@ class TranslatableFile(object):
orig_file = os.path.join(self.dirpath, self.file) orig_file = os.path.join(self.dirpath, self.file)
is_templatized = file_ext in command.extensions is_templatized = file_ext in command.extensions
if is_templatized: if is_templatized:
with open(orig_file, "rU") as fp: with open(orig_file, 'r' if six.PY3 else 'rU') as fp:
src_data = fp.read() src_data = fp.read()
thefile = '%s.py' % self.file thefile = '%s.py' % self.file
content = templatize(src_data, orig_file[2:]) content = templatize(src_data, orig_file[2:])
...@@ -440,7 +441,7 @@ class Command(NoArgsCommand): ...@@ -440,7 +441,7 @@ class Command(NoArgsCommand):
for domain in domains: for domain in domains:
django_po = os.path.join(django_dir, 'conf', 'locale', locale, 'LC_MESSAGES', '%s.po' % domain) django_po = os.path.join(django_dir, 'conf', 'locale', locale, 'LC_MESSAGES', '%s.po' % domain)
if os.path.exists(django_po): if os.path.exists(django_po):
with io.open(django_po, 'rU', encoding='utf-8') as fp: with io.open(django_po, 'r' if six.PY3 else 'rU', encoding='utf-8') as fp:
m = plural_forms_re.search(fp.read()) m = plural_forms_re.search(fp.read())
if m: if m:
plural_form_line = force_str(m.group('value')) plural_form_line = force_str(m.group('value'))
......
...@@ -9,6 +9,7 @@ from django.apps import apps ...@@ -9,6 +9,7 @@ from django.apps import apps
from django.conf import settings from django.conf import settings
from django.core.management.base import CommandError from django.core.management.base import CommandError
from django.db import models, router from django.db import models, router
from django.utils import six
def sql_create(app_config, style, connection): def sql_create(app_config, style, connection):
...@@ -198,7 +199,7 @@ def custom_sql_for_model(model, style, connection): ...@@ -198,7 +199,7 @@ def custom_sql_for_model(model, style, connection):
sql_files.append(os.path.join(app_dir, "%s.sql" % opts.model_name)) sql_files.append(os.path.join(app_dir, "%s.sql" % opts.model_name))
for sql_file in sql_files: for sql_file in sql_files:
if os.path.exists(sql_file): if os.path.exists(sql_file):
with codecs.open(sql_file, 'U', encoding=settings.FILE_CHARSET) as fp: with codecs.open(sql_file, 'r' if six.PY3 else 'U', encoding=settings.FILE_CHARSET) as fp:
# Some backends can't execute more than one SQL statement at a time, # Some backends can't execute more than one SQL statement at a time,
# so split into separate statements. # so split into separate statements.
output.extend(_split_statements(fp.read())) output.extend(_split_statements(fp.read()))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment