diff options
| author | Claude Paroz <claude@2xlibre.net> | 2017-01-07 20:13:29 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2017-01-22 20:08:04 +0100 |
| commit | 6e55e1d88a5c4453e25f0caf7ffb68973de5c0ba (patch) | |
| tree | 4084a5083b9e44ea90e9a119581d09efc9d41228 /django/utils/module_loading.py | |
| parent | d170c63351944fd91b2206d10f89e7ff75b53b76 (diff) | |
Refs #23919 -- Replaced six.reraise by raise
Diffstat (limited to 'django/utils/module_loading.py')
| -rw-r--r-- | django/utils/module_loading.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py index ed2b8da635..5e5fa0e69e 100644 --- a/django/utils/module_loading.py +++ b/django/utils/module_loading.py @@ -1,11 +1,8 @@ import copy import os -import sys from importlib import import_module from importlib.util import find_spec as importlib_find -from django.utils import six - def import_string(dotted_path): """ @@ -14,18 +11,17 @@ def import_string(dotted_path): """ try: module_path, class_name = dotted_path.rsplit('.', 1) - except ValueError: - msg = "%s doesn't look like a module path" % dotted_path - six.reraise(ImportError, ImportError(msg), sys.exc_info()[2]) + except ValueError as err: + raise ImportError("%s doesn't look like a module path" % dotted_path) from err module = import_module(module_path) try: return getattr(module, class_name) - except AttributeError: - msg = 'Module "%s" does not define a "%s" attribute/class' % ( + except AttributeError as err: + raise ImportError('Module "%s" does not define a "%s" attribute/class' % ( module_path, class_name) - six.reraise(ImportError, ImportError(msg), sys.exc_info()[2]) + ) from err def autodiscover_modules(*args, **kwargs): |
