From c485e236bd7e5ea40c64b2fe54d85dbb15b2fd39 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Wed, 18 Mar 2009 16:55:59 +0000 Subject: Fixed #8193: all dynamic imports in Django are now done correctly. I know this because Brett Cannon borrowed the time machine and brought Python 2.7's '`importlib` back for inclusion in Django. Thanks for the patch-from-the-future, Brett! git-svn-id: http://code.djangoproject.com/svn/django/trunk@10088 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/conf/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'django/conf') diff --git a/django/conf/__init__.py b/django/conf/__init__.py index c980ee0b28..7bc7ae9508 100644 --- a/django/conf/__init__.py +++ b/django/conf/__init__.py @@ -12,6 +12,7 @@ import time # Needed for Windows from django.conf import global_settings from django.utils.functional import LazyObject +from django.utils import importlib ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE" @@ -69,7 +70,7 @@ class Settings(object): self.SETTINGS_MODULE = settings_module try: - mod = __import__(self.SETTINGS_MODULE, {}, {}, ['']) + mod = importlib.import_module(self.SETTINGS_MODULE) except ImportError, e: raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e) @@ -89,7 +90,8 @@ class Settings(object): new_installed_apps = [] for app in self.INSTALLED_APPS: if app.endswith('.*'): - appdir = os.path.dirname(__import__(app[:-2], {}, {}, ['']).__file__) + app_mod = importlib.import_module(app[:-2]) + appdir = os.path.dirname(app_mod.__file__) app_subdirs = os.listdir(appdir) app_subdirs.sort() name_pattern = re.compile(r'[a-zA-Z]\w*') -- cgit v1.3