summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-09-30 18:28:48 +0200
committerClaude Paroz <claude@2xlibre.net>2016-10-06 11:41:35 +0200
commit979ea95608176e9c88678fd4d8a096c29654b5f3 (patch)
tree7b49c5d4c3b84a400452ff79803644f0d369637a /django
parente7fa89fb58cc7ba468e0167f506dc4fce7ec532a (diff)
Fixed #27300 -- Made makemigrations --dry-run output a string (no bytes)
Thanks Markus Holtermann for the report and the review.
Diffstat (limited to 'django')
-rw-r--r--django/core/management/commands/makemigrations.py5
-rw-r--r--django/core/management/commands/squashmigrations.py4
-rw-r--r--django/db/migrations/writer.py2
3 files changed, 7 insertions, 4 deletions
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py
index 2fb2d713ca..1fba1a403b 100644
--- a/django/core/management/commands/makemigrations.py
+++ b/django/core/management/commands/makemigrations.py
@@ -1,3 +1,4 @@
+import io
import os
import sys
import warnings
@@ -222,7 +223,7 @@ class Command(BaseCommand):
# We just do this once per app
directory_created[app_label] = True
migration_string = writer.as_string()
- with open(writer.path, "wb") as fh:
+ with io.open(writer.path, "w", encoding='utf-8') as fh:
fh.write(migration_string)
elif self.verbosity == 3:
# Alternatively, makemigrations --dry-run --verbosity 3
@@ -301,7 +302,7 @@ class Command(BaseCommand):
if not self.dry_run:
# Write the merge migrations file to the disk
- with open(writer.path, "wb") as fh:
+ with io.open(writer.path, "w", encoding='utf-8') as fh:
fh.write(writer.as_string())
if self.verbosity > 0:
self.stdout.write("\nCreated new merge migration %s" % writer.path)
diff --git a/django/core/management/commands/squashmigrations.py b/django/core/management/commands/squashmigrations.py
index d9babf85f8..dacc8fe6ce 100644
--- a/django/core/management/commands/squashmigrations.py
+++ b/django/core/management/commands/squashmigrations.py
@@ -1,3 +1,5 @@
+import io
+
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.db import DEFAULT_DB_ALIAS, connections, migrations
@@ -162,7 +164,7 @@ class Command(BaseCommand):
# Write out the new migration file
writer = MigrationWriter(new_migration)
- with open(writer.path, "wb") as fh:
+ with io.open(writer.path, "w", encoding='utf-8') as fh:
fh.write(writer.as_string())
if self.verbosity > 0:
diff --git a/django/db/migrations/writer.py b/django/db/migrations/writer.py
index e75f5bfdd1..df70f61eae 100644
--- a/django/db/migrations/writer.py
+++ b/django/db/migrations/writer.py
@@ -217,7 +217,7 @@ class MigrationWriter(object):
if self.migration.initial:
items['initial_str'] = "\n initial = True\n"
- return (MIGRATION_TEMPLATE % items).encode("utf8")
+ return MIGRATION_TEMPLATE % items
@property
def basedir(self):