diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-11-23 21:44:48 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-11-23 21:44:48 +0000 |
| commit | 08a494c40d33552133fbbe40116d9315c8b9560c (patch) | |
| tree | eac7f3f5ae081916398dd6621cd6deb181cfd136 | |
| parent | fce688cc743bd77c8e415c5a7a409b5fe211e6f7 (diff) | |
Added better error handling for trailing periods in URLconf include()s
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1376 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/urlresolvers.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py index 2a0dda38b8..95cc914676 100644 --- a/django/core/urlresolvers.py +++ b/django/core/urlresolvers.py @@ -7,7 +7,7 @@ a string) and returns a tuple in this format: (view_function, dict_of_view_function_args) """ -from django.core.exceptions import Http404, ViewDoesNotExist +from django.core.exceptions import Http404, ImproperlyConfigured, ViewDoesNotExist import re class Resolver404(Http404): @@ -74,7 +74,11 @@ class RegexURLResolver(object): try: return self._urlconf_module except AttributeError: - self._urlconf_module = __import__(self.urlconf_name, '', '', ['']) + try: + self._urlconf_module = __import__(self.urlconf_name, '', '', ['']) + except ValueError, e: + # Invalid urlconf_name, such as "foo.bar." (note trailing period) + raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e) return self._urlconf_module urlconf_module = property(_get_urlconf_module) |
