From e62d66332f4afccca474651ee0648460a9bbcfa0 Mon Sep 17 00:00:00 2001 From: ianb Date: Thu, 7 Jul 2005 18:33:17 +0000 Subject: Added more information about failed imports --- paste/util/import_string.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'paste/util') diff --git a/paste/util/import_string.py b/paste/util/import_string.py index d3e5771..2d3738c 100644 --- a/paste/util/import_string.py +++ b/paste/util/import_string.py @@ -23,12 +23,14 @@ def simple_import(s): module = import_module(parts[0]) name = parts[0] parts = parts[1:] + last_import_error = None while parts: name += '.' + parts[0] try: module = import_module(name) parts = parts[1:] - except ImportError: + except ImportError, e: + last_import_error = e break obj = module while parts: @@ -36,7 +38,7 @@ def simple_import(s): obj = getattr(module, parts[0]) except AttributeError: raise ImportError( - "Cannot find %s in module %r" % (parts[0], module)) + "Cannot find %s in module %r (stopped importing modules with error %s)" % (parts[0], module, last_import_error)) parts = parts[1:] return obj -- cgit v1.2.1