From a1496b054a2b5182387053952980415543276f8f Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sun, 21 Oct 2007 17:51:06 +0000 Subject: [PATCH] Fixed #5732 -- Catch all possible errors when importing a URLConf file. This leads to error messages that contain the name of the problem file (useful when the problem is part of an include() import). git-svn-id: http://code.djangoproject.com/svn/django/trunk@6584 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/urlresolvers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py index c512c37b962..2ef3d6f1697 100644 --- a/django/core/urlresolvers.py +++ b/django/core/urlresolvers.py @@ -249,8 +249,9 @@ class RegexURLResolver(object): except AttributeError: try: self._urlconf_module = __import__(self.urlconf_name, {}, {}, ['']) - except ValueError, e: - # Invalid urlconf_name, such as "foo.bar." (note trailing period) + except Exception, e: + # Either an invalid urlconf_name, such as "foo.bar.", or some + # kind of problem during the actual import. raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e) return self._urlconf_module urlconf_module = property(_get_urlconf_module)