From 8b78278921fd200167f2cb3b3c3ca401e5cc1921 Mon Sep 17 00:00:00 2001 From: Bruno Clermont Date: Wed, 5 Sep 2012 14:29:05 +0300 Subject: [PATCH] Don't catch AttributeError during cls init if obj = cls() do have an attribute error inside it's initialization, it will appears as if the module could not be find. which is hard to troubleshoot, when the module is really there :) --- configurations/importer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configurations/importer.py b/configurations/importer.py index 7d1dd1a..559ad8d 100644 --- a/configurations/importer.py +++ b/configurations/importer.py @@ -62,11 +62,15 @@ class SettingsLoader(object): mod = imp.load_module(fullname, *self.location) try: cls = getattr(mod, self.name) - obj = cls() except AttributeError: # pragma: no cover raise ImproperlyConfigured("Couldn't find settings '%s' in " "module '%s'" % (self.name, mod.__package__)) + try: + obj = cls() + except Exception, err: + raise ImproperlyConfigured("Couldn't load settings '%s.%s': %s" % + (mod.__name__, self.name, err)) for name, value in uppercase_attributes(obj).items(): if callable(value): value = value()