Ticket #12718: router-attr-error.diff

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

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

  • django/db/utils.py

    diff --git a/django/db/utils.py b/django/db/utils.py
    index 83e2452..67cfe33 100644
    a b class ConnectionRouter(object): 
    9595                try:
    9696                    module_name, klass_name = r.rsplit('.', 1)
    9797                    module = import_module(module_name)
    98                     router = getattr(module, klass_name)()
    9998                except ImportError, e:
    10099                    raise ImproperlyConfigured('Error importing database router %s: "%s"' % (klass_name, e))
     100                try:
     101                    router = getattr(module, klass_name)()
    101102                except AttributeError:
    102103                    raise ImproperlyConfigured('Module "%s" does not define a "%s" database router' % (module, klass_name))
    103104            else:
Back to Top