Database backend refactor suppresses ImproperlyConfigured exceptions

3 views
Skip to first unread message

Karen Tracey

unread,
Aug 22, 2008, 9:07:55 AM8/22/08
to django-d...@googlegroups.com
I noticed a thread on the user's list (http://groups.google.com/group/django-users/browse_thread/thread/c0d55dfea1f2a43c#) reporting that the result of trying to trying to run with the database backend set to 'mysql' but no MySQLdb installed is now the simple message:

Error: No module named mysql.base

whereas as I recalled it used to generate a full traceback ending with:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

This change is the result of changeset 8296, the database backend refactoring.  I'm thinking this change was not intentional -- the ImproperlyConfigured message is better in that it directly points to what the problem is.  Also, I think (though I don't have a machine set up this way to verify at the moment) that the other ImproperlyConfigured exception raised by mysql/base.py:

    raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__)

will now also get suppressed and turned into simply "Error: No module named mysql.base".  Shouldn't the ImproperlyConfigured form the backend's base.py get propogated up so that the real cause of the error (MySQLdb either missing or too old) can be seen?

(Someone did reopen an old ticket, #5531 reporting that the MySQLdb version requirement was not being properly reported, but since in fact the re-opener did not have MySQLdb installed at all, it was re-closed as not a problem.  So I figured I'd ask here before opening another ticket.)

Karen

Russell Keith-Magee

unread,
Aug 22, 2008, 9:34:20 AM8/22/08
to django-d...@googlegroups.com
On Fri, Aug 22, 2008 at 9:07 PM, Karen Tracey <kmtr...@gmail.com> wrote:
> Shouldn't the ImproperlyConfigured form the backend's base.py
> get propogated up so that the real cause of the error (MySQLdb either
> missing or too old) can be seen?

This change certainly wasn't intentional. Looking at the code, I
suspect Oracle will also be affected. The problem will be that
mysql.base imports mysql.introspection, which in turn imports MySQLdb.
This happens before the MySQLdb check at the top of mysql.base, so the
exception you get isn't the old ImproperlyConfigured exception.

I suspect that re-ordering the imports at the top of mysql.base will
fix this problem. Open a ticket and I'll put this on my todo list.

Yours,
Russ Magee %-)

Karen Tracey

unread,
Aug 22, 2008, 10:04:17 AM8/22/08
to django-d...@googlegroups.com
On Fri, Aug 22, 2008 at 9:34 AM, Russell Keith-Magee <freakb...@gmail.com> wrote:
I suspect that re-ordering the imports at the top of mysql.base will
fix this problem. Open a ticket and I'll put this on my todo list.


Done, #8485.

Thanks,
Karen

Reply all
Reply to author
Forward
0 new messages