List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:December 22 2000 12:09am
Subject:MySQL 3.23.29a breaks Python MySQLdb module (+fix)
View as plain text  
After upgrading to MySQL 3.23.29a-gamma, my Python scripts immediately
began to fail.  The problem turned out to be the inclusion of a non-digit
character in the version string immediately after the "29".  Here's a patch
I posted to the Python DB-SIG mailing list.

I just updated to MySQL
3.23.29a-gamma, and found that the "a" caused MySQLdb 0.3.0 to cough
at the code that splits the three numeric hunks out of the version string.
(Normally versions are n.nn.nn-xxxx, where n is a digit.)

I find that this fixes the problem (split on dots, strip non-digit
stuff from third component):

--- MySQLdb.py.orig	Tue Oct 31 13:51:19 2000
+++ MySQLdb.py	Thu Dec 21 14:47:23 2000
@@ -454,7 +454,9 @@
          self.db = apply(connect, (), kwargs)
          self.quote_conv[types.StringType] = self.Thing2Literal
          self._server_info = self.db.get_server_info()
-        i = map(int, split(split(self._server_info, '-')[0],'.'))
+        i = split(self._server_info,'.')
+        i[2] = re.sub('\D*$','',i[2])
+        i = map(int, i);
          self._server_version = i[0]*10000 + i[1]*100 + i[2]
          if _threading: self.__lock = _threading.Lock()

I suspect this will a problem for any code that assumes the server
version string to be three dot-separated numbers followed immediately
by a "-xxxxx" suffix.

-- 
Paul DuBois, paul@stripped
Thread
MySQL 3.23.29a breaks Python MySQLdb module (+fix)Paul DuBois22 Dec