mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-14 18:12:35 +08:00
Improved support for Python 3.
This commit is contained in:
@ -33,7 +33,11 @@ def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
|
|||||||
connection.messages.append(error)
|
connection.messages.append(error)
|
||||||
del cursor
|
del cursor
|
||||||
del connection
|
del connection
|
||||||
raise errorclass, errorvalue
|
if errorclass is not None:
|
||||||
|
raise errorclass(errorvalue)
|
||||||
|
else:
|
||||||
|
raise Exception(errorvalue)
|
||||||
|
|
||||||
|
|
||||||
re_numeric_part = re.compile(r"^(\d+)")
|
re_numeric_part = re.compile(r"^(\d+)")
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class BaseCursor(object):
|
|||||||
try:
|
try:
|
||||||
r = None
|
r = None
|
||||||
r = self._query(query)
|
r = self._query(query)
|
||||||
except TypeError, m:
|
except TypeError as m:
|
||||||
if m.args[0] in ("not enough arguments for format string",
|
if m.args[0] in ("not enough arguments for format string",
|
||||||
"not all arguments converted"):
|
"not all arguments converted"):
|
||||||
self.messages.append((ProgrammingError, m.args[0]))
|
self.messages.append((ProgrammingError, m.args[0]))
|
||||||
@ -247,7 +247,7 @@ class BaseCursor(object):
|
|||||||
for key, item in a.iteritems()))
|
for key, item in a.iteritems()))
|
||||||
else:
|
else:
|
||||||
q.append(qv % tuple([db.literal(item) for item in a]))
|
q.append(qv % tuple([db.literal(item) for item in a]))
|
||||||
except TypeError, msg:
|
except TypeError as msg:
|
||||||
if msg.args[0] in ("not enough arguments for format string",
|
if msg.args[0] in ("not enough arguments for format string",
|
||||||
"not all arguments converted"):
|
"not all arguments converted"):
|
||||||
self.errorhandler(self, ProgrammingError, msg.args[0])
|
self.errorhandler(self, ProgrammingError, msg.args[0])
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
import os, sys
|
import os, sys
|
||||||
from ConfigParser import SafeConfigParser
|
try:
|
||||||
|
from ConfigParser import SafeConfigParser
|
||||||
|
except ImportError:
|
||||||
|
# Probably running Python 3.x
|
||||||
|
from configparser import ConfigParser as SafeConfigParser
|
||||||
|
|
||||||
# This dequote() business is required for some older versions
|
# This dequote() business is required for some older versions
|
||||||
# of mysql_config
|
# of mysql_config
|
||||||
|
@ -76,7 +76,7 @@ class test_MySQLdb(capabilities.DatabaseTest):
|
|||||||
from MySQLdb.constants import ER
|
from MySQLdb.constants import ER
|
||||||
try:
|
try:
|
||||||
self.cursor.execute("describe some_non_existent_table");
|
self.cursor.execute("describe some_non_existent_table");
|
||||||
except self.connection.ProgrammingError, msg:
|
except self.connection.ProgrammingError as msg:
|
||||||
self.assertEquals(msg[0], ER.NO_SUCH_TABLE)
|
self.assertEquals(msg[0], ER.NO_SUCH_TABLE)
|
||||||
|
|
||||||
def test_bug_3514287(self):
|
def test_bug_3514287(self):
|
||||||
|
Reference in New Issue
Block a user