Commit 5d263dee authored by Berker Peksag's avatar Berker Peksag Committed by Tim Graham
Browse files

Fixed #21674 -- Deprecated the import_by_path() function in favor of import_string().

Thanks Aymeric Augustin for the suggestion and review.
parent fcc21837
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -484,6 +484,7 @@ answer newbie questions, and generally made Django that much better:
    John Paulett <john@paulett.org>
    pavithran s <pavithran.s@gmail.com>
    Barry Pederson <bp@barryp.org>
    Berker Peksag <berker.peksag@gmail.com>
    Andreas Pelme <andreas@pelme.se>
    permonik@mesias.brnonet.cz
    peter@mymart.com
+2 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ import os
from unittest import SkipTest

from django.contrib.staticfiles.testing import StaticLiveServerCase
from django.utils.module_loading import import_by_path
from django.utils.module_loading import import_string
from django.utils.translation import ugettext as _


@@ -22,7 +22,7 @@ class AdminSeleniumWebDriverTestCase(StaticLiveServerCase):
        if not os.environ.get('DJANGO_SELENIUM_TESTS', False):
            raise SkipTest('Selenium tests not requested')
        try:
            cls.selenium = import_by_path(cls.webdriver_class)()
            cls.selenium = import_string(cls.webdriver_class)()
        except Exception as e:
            raise SkipTest('Selenium webdriver "%s" not installed or not '
                           'operational: %s' % (cls.webdriver_class, str(e)))
+2 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ import re
from django.apps import apps as django_apps
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
from django.utils.module_loading import import_by_path
from django.utils.module_loading import import_string
from django.middleware.csrf import rotate_token

from .signals import user_logged_in, user_logged_out, user_login_failed
@@ -15,7 +15,7 @@ REDIRECT_FIELD_NAME = 'next'


def load_backend(path):
    return import_by_path(path)()
    return import_string(path)()


def get_backends():
+2 −2
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ from django.utils.encoding import force_bytes, force_str, force_text
from django.core.exceptions import ImproperlyConfigured
from django.utils.crypto import (
    pbkdf2, constant_time_compare, get_random_string)
from django.utils.module_loading import import_by_path
from django.utils.module_loading import import_string
from django.utils.translation import ugettext_noop as _


@@ -92,7 +92,7 @@ def load_hashers(password_hashers=None):
    if not password_hashers:
        password_hashers = settings.PASSWORD_HASHERS
    for backend in password_hashers:
        hasher = import_by_path(backend)()
        hasher = import_string(backend)()
        if not getattr(hasher, 'algorithm'):
            raise ImproperlyConfigured("hasher doesn't specify an "
                                       "algorithm name: %s" % backend)
+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ class RemoteUserMiddleware(object):
                        auth.BACKEND_SESSION_KEY, ''))
                    if isinstance(stored_backend, RemoteUserBackend):
                        auth.logout(request)
                except ImproperlyConfigured:
                except ImportError:
                    # backend failed to load
                    auth.logout(request)
            return
Loading