Code

Ticket #12718: router-attr-error.diff

File router-attr-error.diff, 803 bytes (added by jbalogh, 4 years ago)

if there's an AttributeError in the router module, it gets swallowed up by the wrong except

Line 
1diff --git a/django/db/utils.py b/django/db/utils.py
2index 83e2452..67cfe33 100644
3--- a/django/db/utils.py
4+++ b/django/db/utils.py
5@@ -95,9 +95,10 @@ class ConnectionRouter(object):
6                 try:
7                     module_name, klass_name = r.rsplit('.', 1)
8                     module = import_module(module_name)
9-                    router = getattr(module, klass_name)()
10                 except ImportError, e:
11                     raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e))
12+                try:
13+                    router = getattr(module, klass_name)()
14                 except AttributeError:
15                     raise ImproperlyConfigured('Module "%s" does not define a "%s" database router' % (module, klass_name))
16             else: