summaryrefslogtreecommitdiff
path: root/django/core/management
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-12-08 11:13:52 +0100
committerClaude Paroz <claude@2xlibre.net>2012-12-08 11:13:52 +0100
commitc91667338a4e774e2819ccf4da852dc7b759bc19 (patch)
tree42a700d237c85ac2b647999d02d3dcd7d8047068 /django/core/management
parent53b879f045f0e55cc8f4bedff67b5a14f3057561 (diff)
Fixed #19357 -- Allow non-ASCII chars in filesystem paths
Thanks kujiu for the report and Aymeric Augustin for the review.
Diffstat (limited to 'django/core/management')
-rw-r--r--django/core/management/__init__.py7
-rw-r--r--django/core/management/commands/compilemessages.py5
-rw-r--r--django/core/management/commands/loaddata.py5
-rw-r--r--django/core/management/commands/makemessages.py6
-rw-r--r--django/core/management/sql.py3
5 files changed, 15 insertions, 11 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index bb26c20666..fab5059376 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -9,6 +9,7 @@ from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, CommandError, handle_default_options
from django.core.management.color import color_style
from django.utils.importlib import import_module
+from django.utils._os import upath
from django.utils import six
# For backwards compatibility: get_version() used to be in this module.
@@ -410,10 +411,10 @@ def setup_environ(settings_mod, original_settings_path=None):
# Add this project to sys.path so that it's importable in the conventional
# way. For example, if this file (manage.py) lives in a directory
# "myproject", this code would add "/path/to/myproject" to sys.path.
- if '__init__.py' in settings_mod.__file__:
- p = os.path.dirname(settings_mod.__file__)
+ if '__init__.py' in upath(settings_mod.__file__):
+ p = os.path.dirname(upath(settings_mod.__file__))
else:
- p = settings_mod.__file__
+ p = upath(settings_mod.__file__)
project_directory, settings_filename = os.path.split(p)
if project_directory == os.curdir or not project_directory:
project_directory = os.getcwd()
diff --git a/django/core/management/commands/compilemessages.py b/django/core/management/commands/compilemessages.py
index b7392b9173..e1d8a33332 100644
--- a/django/core/management/commands/compilemessages.py
+++ b/django/core/management/commands/compilemessages.py
@@ -5,6 +5,7 @@ import os
import sys
from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
+from django.utils._os import npath
def has_bom(fn):
with open(fn, 'rb') as f:
@@ -41,8 +42,8 @@ def compile_messages(stderr, locale=None):
# command, so that we can take advantage of shell quoting, to
# quote any malicious characters/escaping.
# See http://cyberelk.net/tim/articles/cmdline/ar01s02.html
- os.environ['djangocompilemo'] = pf + '.mo'
- os.environ['djangocompilepo'] = pf + '.po'
+ os.environ['djangocompilemo'] = npath(pf + '.mo')
+ os.environ['djangocompilepo'] = npath(pf + '.po')
if sys.platform == 'win32': # Different shell-variable syntax
cmd = 'msgfmt --check-format -o "%djangocompilemo%" "%djangocompilepo%"'
else:
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index f6f1b1039a..ed47b8fbf1 100644
--- a/django/core/management/commands/loaddata.py
+++ b/django/core/management/commands/loaddata.py
@@ -13,6 +13,7 @@ from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS,
IntegrityError, DatabaseError)
from django.db.models import get_apps
from django.utils.encoding import force_text
+from django.utils._os import upath
from itertools import product
try:
@@ -97,10 +98,10 @@ class Command(BaseCommand):
if hasattr(app, '__path__'):
# It's a 'models/' subpackage
for path in app.__path__:
- app_module_paths.append(path)
+ app_module_paths.append(upath(path))
else:
# It's a models.py module
- app_module_paths.append(app.__file__)
+ app_module_paths.append(upath(app.__file__))
app_fixtures = [os.path.join(os.path.dirname(path), 'fixtures') for path in app_module_paths]
diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index 81c4fdf8cc..606cbe0b85 100644
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -301,7 +301,7 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
locales = []
if locale is not None:
- locales.append(locale)
+ locales.append(str(locale))
elif all:
locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir))
locales = [os.path.basename(l) for l in locale_dirs]
@@ -316,8 +316,8 @@ def make_messages(locale=None, domain='django', verbosity=1, all=False,
if not os.path.isdir(basedir):
os.makedirs(basedir)
- pofile = os.path.join(basedir, '%s.po' % domain)
- potfile = os.path.join(basedir, '%s.pot' % domain)
+ pofile = os.path.join(basedir, '%s.po' % str(domain))
+ potfile = os.path.join(basedir, '%s.pot' % str(domain))
if os.path.exists(potfile):
os.unlink(potfile)
diff --git a/django/core/management/sql.py b/django/core/management/sql.py
index ea03e9088c..e46f4ae4f5 100644
--- a/django/core/management/sql.py
+++ b/django/core/management/sql.py
@@ -8,6 +8,7 @@ from django.conf import settings
from django.core.management.base import CommandError
from django.db import models
from django.db.models import get_models
+from django.utils._os import upath
def sql_create(app, style, connection):
@@ -159,7 +160,7 @@ def _split_statements(content):
def custom_sql_for_model(model, style, connection):
opts = model._meta
- app_dir = os.path.normpath(os.path.join(os.path.dirname(models.get_app(model._meta.app_label).__file__), 'sql'))
+ app_dir = os.path.normpath(os.path.join(os.path.dirname(upath(models.get_app(model._meta.app_label).__file__)), 'sql'))
output = []
# Post-creation SQL should come before any initial SQL data is loaded.