summaryrefslogtreecommitdiff
path: root/django/utils
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-01-20 08:01:02 -0500
committerGitHub <noreply@github.com>2017-01-20 08:01:02 -0500
commit4e729feaa647547f25debb1cb63dec989dc41a20 (patch)
tree7c7a38c5961bf4daf98a8cb47dc74c769563ffcf /django/utils
parentec4c1d6717da7a9d09d5b3ce84cccac819bb592c (diff)
Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.
These functions do nothing on Python 3.
Diffstat (limited to 'django/utils')
-rw-r--r--django/utils/_os.py11
-rw-r--r--django/utils/autoreload.py3
-rw-r--r--django/utils/translation/trans_real.py5
3 files changed, 8 insertions, 11 deletions
diff --git a/django/utils/_os.py b/django/utils/_os.py
index 6507e58764..8309e08fbf 100644
--- a/django/utils/_os.py
+++ b/django/utils/_os.py
@@ -5,20 +5,19 @@ from os.path import abspath, dirname, join, normcase, sep
from django.core.exceptions import SuspiciousFileOperation
from django.utils.encoding import force_text
+# For backwards-compatibility in Django 2.0
abspathu = abspath
def upath(path):
- """
- Always return a unicode path.
- """
+ """Always return a unicode path (did something for Python 2)."""
return path
def npath(path):
"""
Always return a native path, that is unicode on Python 3 and bytestring on
- Python 2.
+ Python 2. Noop for Python 3.
"""
return path
@@ -33,8 +32,8 @@ def safe_join(base, *paths):
"""
base = force_text(base)
paths = [force_text(p) for p in paths]
- final_path = abspathu(join(base, *paths))
- base_path = abspathu(base)
+ final_path = abspath(join(base, *paths))
+ base_path = abspath(base)
# Ensure final_path starts with base_path (using normcase to ensure we
# don't false-negative on case insensitive operating systems like Windows),
# further, one of the following conditions must be true:
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index d6a5b1a319..6255da1c84 100644
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -41,7 +41,6 @@ from django.apps import apps
from django.conf import settings
from django.core.signals import request_finished
from django.utils import six
-from django.utils._os import npath
# This import does nothing, but it's necessary to avoid some race conditions
# in the threading module. See http://code.djangoproject.com/ticket/2330 .
@@ -111,7 +110,7 @@ def gen_filenames(only_new=False):
'conf', 'locale'),
'locale']
for app_config in reversed(list(apps.get_app_configs())):
- basedirs.append(os.path.join(npath(app_config.path), 'locale'))
+ basedirs.append(os.path.join(app_config.path, 'locale'))
basedirs.extend(settings.LOCALE_PATHS)
basedirs = [os.path.abspath(basedir) for basedir in basedirs
if os.path.isdir(basedir)]
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 99acda9aab..14bb0ce786 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -14,7 +14,6 @@ from django.conf.locale import LANG_INFO
from django.core.exceptions import AppRegistryNotReady
from django.core.signals import setting_changed
from django.dispatch import receiver
-from django.utils._os import upath
from django.utils.encoding import force_text
from django.utils.safestring import SafeData, mark_safe
from django.utils.translation import LANGUAGE_SESSION_KEY
@@ -155,7 +154,7 @@ class DjangoTranslation(gettext_module.GNUTranslations):
def _init_translation_catalog(self):
"""Creates a base catalog using global django translations."""
- settingsfile = upath(sys.modules[settings.__module__].__file__)
+ settingsfile = sys.modules[settings.__module__].__file__
localedir = os.path.join(os.path.dirname(settingsfile), 'locale')
translation = self._new_gnu_trans(localedir)
self.merge(translation)
@@ -399,7 +398,7 @@ def all_locale_paths():
Returns a list of paths to user-provides languages files.
"""
globalpath = os.path.join(
- os.path.dirname(upath(sys.modules[settings.__module__].__file__)), 'locale')
+ os.path.dirname(sys.modules[settings.__module__].__file__), 'locale')
return [globalpath] + list(settings.LOCALE_PATHS)