mirror of
https://github.com/django/django.git
synced 2025-10-28 16:16:12 +00:00
Fixed #2968 -- Changed arguments to __import__ to use empty dictionary instead of empty string, for stricter compliance with Python library reference. Thanks for the patch, Yasushi Masuda
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3951 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
2
django/core/cache/__init__.py
vendored
2
django/core/cache/__init__.py
vendored
@@ -48,7 +48,7 @@ def get_cache(backend_uri):
|
||||
if host.endswith('/'):
|
||||
host = host[:-1]
|
||||
|
||||
cache_class = getattr(__import__('django.core.cache.backends.%s' % BACKENDS[scheme], '', '', ['']), 'CacheClass')
|
||||
cache_class = getattr(__import__('django.core.cache.backends.%s' % BACKENDS[scheme], {}, {}, ['']), 'CacheClass')
|
||||
return cache_class(host, params)
|
||||
|
||||
cache = get_cache(settings.CACHE_BACKEND)
|
||||
|
||||
@@ -26,7 +26,7 @@ class BaseHandler(object):
|
||||
raise exceptions.ImproperlyConfigured, '%s isn\'t a middleware module' % middleware_path
|
||||
mw_module, mw_classname = middleware_path[:dot], middleware_path[dot+1:]
|
||||
try:
|
||||
mod = __import__(mw_module, '', '', [''])
|
||||
mod = __import__(mw_module, {}, {}, [''])
|
||||
except ImportError, e:
|
||||
raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' % (mw_module, e)
|
||||
try:
|
||||
|
||||
@@ -446,7 +446,7 @@ def syncdb(verbosity=1, interactive=True):
|
||||
# dispatcher events.
|
||||
for app_name in settings.INSTALLED_APPS:
|
||||
try:
|
||||
__import__(app_name + '.management', '', '', [''])
|
||||
__import__(app_name + '.management', {}, {}, [''])
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -1230,7 +1230,7 @@ def test(app_labels, verbosity=1):
|
||||
test_module_name = '.'.join(test_path[:-1])
|
||||
else:
|
||||
test_module_name = '.'
|
||||
test_module = __import__(test_module_name, [],[],test_path[-1])
|
||||
test_module = __import__(test_module_name, {}, {}, test_path[-1])
|
||||
test_runner = getattr(test_module, test_path[-1])
|
||||
|
||||
test_runner(app_list, verbosity)
|
||||
@@ -1419,7 +1419,7 @@ def setup_environ(settings_mod):
|
||||
project_directory = os.path.dirname(settings_mod.__file__)
|
||||
project_name = os.path.basename(project_directory)
|
||||
sys.path.append(os.path.join(project_directory, '..'))
|
||||
project_module = __import__(project_name, '', '', [''])
|
||||
project_module = __import__(project_name, {}, {}, [''])
|
||||
sys.path.pop()
|
||||
|
||||
# Set DJANGO_SETTINGS_MODULE appropriately.
|
||||
|
||||
@@ -29,7 +29,7 @@ _serializers = {}
|
||||
|
||||
def register_serializer(format, serializer_module):
|
||||
"""Register a new serializer by passing in a module name."""
|
||||
module = __import__(serializer_module, '', '', [''])
|
||||
module = __import__(serializer_module, {}, {}, [''])
|
||||
_serializers[format] = module
|
||||
|
||||
def unregister_serializer(format):
|
||||
|
||||
@@ -119,7 +119,7 @@ class RegexURLPattern(object):
|
||||
return self._callback
|
||||
mod_name, func_name = get_mod_func(self._callback_str)
|
||||
try:
|
||||
self._callback = getattr(__import__(mod_name, '', '', ['']), func_name)
|
||||
self._callback = getattr(__import__(mod_name, {}, {}, ['']), func_name)
|
||||
except ImportError, e:
|
||||
raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))
|
||||
except AttributeError, e:
|
||||
@@ -130,7 +130,7 @@ class RegexURLPattern(object):
|
||||
def reverse(self, viewname, *args, **kwargs):
|
||||
mod_name, func_name = get_mod_func(viewname)
|
||||
try:
|
||||
lookup_view = getattr(__import__(mod_name, '', '', ['']), func_name)
|
||||
lookup_view = getattr(__import__(mod_name, {}, {}, ['']), func_name)
|
||||
except (ImportError, AttributeError):
|
||||
raise NoReverseMatch
|
||||
if lookup_view != self.callback:
|
||||
@@ -171,7 +171,7 @@ class RegexURLResolver(object):
|
||||
return self._urlconf_module
|
||||
except AttributeError:
|
||||
try:
|
||||
self._urlconf_module = __import__(self.urlconf_name, '', '', [''])
|
||||
self._urlconf_module = __import__(self.urlconf_name, {}, {}, [''])
|
||||
except ValueError, e:
|
||||
# Invalid urlconf_name, such as "foo.bar." (note trailing period)
|
||||
raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e)
|
||||
@@ -186,7 +186,7 @@ class RegexURLResolver(object):
|
||||
callback = getattr(self.urlconf_module, 'handler%s' % view_type)
|
||||
mod_name, func_name = get_mod_func(callback)
|
||||
try:
|
||||
return getattr(__import__(mod_name, '', '', ['']), func_name), {}
|
||||
return getattr(__import__(mod_name, {}, {}, ['']), func_name), {}
|
||||
except (ImportError, AttributeError), e:
|
||||
raise ViewDoesNotExist, "Tried %s. Error was: %s" % (callback, str(e))
|
||||
|
||||
@@ -200,7 +200,7 @@ class RegexURLResolver(object):
|
||||
if not callable(lookup_view):
|
||||
mod_name, func_name = get_mod_func(lookup_view)
|
||||
try:
|
||||
lookup_view = getattr(__import__(mod_name, '', '', ['']), func_name)
|
||||
lookup_view = getattr(__import__(mod_name, {}, {}, ['']), func_name)
|
||||
except (ImportError, AttributeError):
|
||||
raise NoReverseMatch
|
||||
for pattern in self.urlconf_module.urlpatterns:
|
||||
|
||||
Reference in New Issue
Block a user