Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion MySQLdb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
connection.messages.append(error)
del cursor
del connection
raise errorclass, errorvalue
if errorclass is not None:
raise errorclass(errorvalue)
else:
raise Exception(errorvalue)


re_numeric_part = re.compile(r"^(\d+)")

Expand Down
4 changes: 2 additions & 2 deletions MySQLdb/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def execute(self, query, args=None):
try:
r = None
r = self._query(query)
except TypeError, m:
except TypeError as m:
if m.args[0] in ("not enough arguments for format string",
"not all arguments converted"):
self.messages.append((ProgrammingError, m.args[0]))
Expand Down Expand Up @@ -247,7 +247,7 @@ def executemany(self, query, args):
for key, item in a.iteritems()))
else:
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",
"not all arguments converted"):
self.errorhandler(self, ProgrammingError, msg.args[0])
Expand Down
6 changes: 5 additions & 1 deletion setup_posix.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import os, sys
from ConfigParser import SafeConfigParser
try:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use:

from setup_common import SafeConfigParser

See #59

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
# of mysql_config
Expand Down
4 changes: 2 additions & 2 deletions tests/test_MySQLdb_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def test_bug_2671682(self):
from MySQLdb.constants import ER
try:
self.cursor.execute("describe some_non_existent_table");
except self.connection.ProgrammingError, msg:
self.assertEquals(msg[0], ER.NO_SUCH_TABLE)
except self.connection.ProgrammingError as msg:
self.assertTrue(str(ER.NO_SUCH_TABLE) in str(msg))

def test_bug_3514287(self):
c = self.cursor
Expand Down