From: Vinay Sajip Date: Wed, 2 Jun 2010 10:05:31 +0000 (+0000) Subject: Logging: improved error reporting for BaseConfigurator.resolve(). X-Git-Tag: v2.7rc1~51 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b4849a21d691bf95b9d4d4171b60c496e109ae6;p=python Logging: improved error reporting for BaseConfigurator.resolve(). --- diff --git a/Lib/logging/config.py b/Lib/logging/config.py index 07b9d1a834..356183f5ed 100644 --- a/Lib/logging/config.py +++ b/Lib/logging/config.py @@ -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."""