Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installable under Python 3.3 #48

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions setup_common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

try:
# Python 2.x
from ConfigParser import SafeConfigParser
Expand Down
7 changes: 5 additions & 2 deletions setup_posix.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os, sys
from ConfigParser import SafeConfigParser
# -*- coding: utf-8 -*-

import os
import sys
from setup_common import 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