summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-03-18 19:16:47 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-03-18 19:16:47 +0000
commitcb624b137772fbfbfd3882df4d632734259a1565 (patch)
tree93ef2edbeeb3f30efcf6655a0b77199f297b7ab6
parentf765aa4e4475d7c3df20beb1c6e0f1ef5c4edc27 (diff)
Fixed #3747 -- Added a stricter MySQLdb version check so that (1, 2, 1,
'final', 2) passes and (1, 2, 1, 'gamma') does not. Also fixed a problem in the error reporting when the check fails. git-svn-id: http://code.djangoproject.com/svn/django/trunk@4751 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/backends/mysql/base.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index cbe080144c..081c1185a5 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -10,8 +10,14 @@ try:
except ImportError, e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured, "Error loading MySQLdb module: %s" % e
-if Database.version_info < (1,2,1,'final',2):
- raise ImportError, "MySQLdb-1.2.1p2 or newer is required; you have %s" % MySQLdb.__version__
+
+# We want version (1, 2, 1, 'final', 2) or later. We can't just use
+# lexicographic ordering in this check because then (1, 2, 1, 'gamma')
+# inadvertently passes the version test.
+version = Database.version_info
+if (version < (1,2,1) or (version[:3] == (1, 2, 1) and
+ (len(version) < 5 or version[3] != 'final' or version[4] < 2))):
+ raise ImportError, "MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__
from MySQLdb.converters import conversions
from MySQLdb.constants import FIELD_TYPE