[1.8.x] Refs #24324 -- Fixed UnicodeDecodeError in makemigrations.

If the project path contained a non-ASCII character, Python 2 crashed.

Backport of c9ece2e6b9 from master
This commit is contained in:
Tim Graham 2015-02-14 19:51:43 -05:00
parent 4f43e5c435
commit ba3a7636f1
1 changed files with 2 additions and 1 deletions

View File

@ -15,6 +15,7 @@ from django.apps import apps
from django.db import migrations, models from django.db import migrations, models
from django.db.migrations.loader import MigrationLoader from django.db.migrations.loader import MigrationLoader
from django.utils import datetime_safe, six from django.utils import datetime_safe, six
from django.utils._os import upath
from django.utils.encoding import force_text from django.utils.encoding import force_text
from django.utils.functional import Promise from django.utils.functional import Promise
from django.utils.timezone import utc from django.utils.timezone import utc
@ -212,7 +213,7 @@ class MigrationWriter(object):
if not hasattr(migrations_module, '__file__'): if not hasattr(migrations_module, '__file__'):
raise ImportError raise ImportError
basedir = os.path.dirname(migrations_module.__file__) basedir = os.path.dirname(upath(migrations_module.__file__))
except ImportError: except ImportError:
app_config = apps.get_app_config(self.migration.app_label) app_config = apps.get_app_config(self.migration.app_label)
migrations_package_basename = migrations_package_name.split(".")[-1] migrations_package_basename = migrations_package_name.split(".")[-1]