diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-03-18 16:55:59 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-03-18 16:55:59 +0000 |
| commit | c485e236bd7e5ea40c64b2fe54d85dbb15b2fd39 (patch) | |
| tree | fc5e86abf39b69181b2084f5c39038f1811b6b44 /django/conf | |
| parent | ee2f04d79e5bca55637b9bb3301618738a4e342a (diff) | |
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
Diffstat (limited to 'django/conf')
| -rw-r--r-- | django/conf/__init__.py | 6 |
1 files changed, 4 insertions, 2 deletions
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*') |
