]> granicus.if.org Git - python/commitdiff
Logging: improved error reporting for BaseConfigurator.resolve().
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 2 Jun 2010 10:05:31 +0000 (10:05 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 2 Jun 2010 10:05:31 +0000 (10:05 +0000)
Lib/logging/config.py

index 07b9d1a8342ac6b56d53daa48033dd34c87e5f18..356183f5ed0c968a4060083d45eca13b31353a49 100644 (file)
@@ -387,15 +387,21 @@ class BaseConfigurator(object):
         """
         name = s.split('.')
         used = name.pop(0)
-        found = self.importer(used)
-        for frag in name:
-            used += '.' + frag
-            try:
-                found = getattr(found, frag)
-            except AttributeError:
-                self.importer(used)
-                found = getattr(found, frag)
-        return found
+        try:
+            found = self.importer(used)
+            for frag in name:
+                used += '.' + frag
+                try:
+                    found = getattr(found, frag)
+                except AttributeError:
+                    self.importer(used)
+                    found = getattr(found, frag)
+            return found
+        except ImportError:
+            e, tb = sys.exc_info()[1:]
+            v = ValueError('Cannot resolve %r: %s' % (s, e))
+            v.__cause__, v.__traceback__ = e, tb
+            raise v
 
     def ext_convert(self, value):
         """Default converter for the ext:// protocol."""