From 6e55e1d88a5c4453e25f0caf7ffb68973de5c0ba Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 7 Jan 2017 20:13:29 +0100 Subject: Refs #23919 -- Replaced six.reraise by raise --- django/utils/module_loading.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'django/utils/module_loading.py') 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): -- cgit v1.3