Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8041cc6

Browse filesBrowse files
author
adustman
committed
Some (many) tests actually pass now on Python 3. May no longer be backwards-compatible with Python < 2.6.
1 parent fe917fc commit 8041cc6
Copy full SHA for 8041cc6

File tree

Expand file treeCollapse file tree

8 files changed

+24
-20
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+24
-20
lines changed

‎MySQLdb/MySQLdb/__init__.py

Copy file name to clipboardExpand all lines: MySQLdb/MySQLdb/__init__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def Binary(x):
7777

7878
def Connect(*args, **kwargs):
7979
"""Factory function for connections.Connection."""
80-
from connections import Connection
80+
from MySQLdb.connections import Connection
8181
return Connection(*args, **kwargs)
8282

8383
connect = Connection = Connect

‎MySQLdb/MySQLdb/connections.py

Copy file name to clipboardExpand all lines: MySQLdb/MySQLdb/connections.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
override Connection.default_cursor with a non-standard Cursor class.
77
88
"""
9-
import cursors
9+
from MySQLdb import cursors
1010
from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \
1111
DatabaseError, OperationalError, IntegrityError, InternalError, \
1212
NotSupportedError, ProgrammingError
@@ -33,7 +33,7 @@ def defaulterrorhandler(connection, cursor, errorclass, errorvalue):
3333
connection.messages.append(error)
3434
del cursor
3535
del connection
36-
raise errorclass, errorvalue
36+
raise errorclass(errorvalue)
3737

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

@@ -143,8 +143,8 @@ class object, used to create cursors (keyword only)
143143
documentation for the MySQL C API for some hints on what they do.
144144
145145
"""
146-
from constants import CLIENT, FIELD_TYPE
147-
from converters import conversions
146+
from MySQLdb.constants import CLIENT, FIELD_TYPE
147+
from MySQLdb.converters import conversions
148148
from weakref import proxy, WeakValueDictionary
149149

150150
import types

‎MySQLdb/MySQLdb/converters.py

Copy file name to clipboardExpand all lines: MySQLdb/MySQLdb/converters.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"""
3434

3535
from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL
36-
from constants import FIELD_TYPE, FLAG
37-
from times import *
36+
from MySQLdb.constants import FIELD_TYPE, FLAG
37+
from MySQLdb.times import *
3838
import types
3939
import array
4040

‎MySQLdb/MySQLdb/cursors.py

Copy file name to clipboardExpand all lines: MySQLdb/MySQLdb/cursors.py
+10-5Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77

88
import re
99
import sys
10-
from types import ListType, TupleType, UnicodeType
11-
10+
try:
11+
from types import ListType, TupleType, UnicodeType
12+
except ImportError:
13+
# Python 3
14+
ListType = list
15+
TupleType = tuple
16+
UnicodeType = str
1217

1318
restr = (r"\svalues\s*"
1419
r"(\(((?<!\\)'[^\)]*?\)[^\)]*(?<!\\)?'"
@@ -161,7 +166,7 @@ def execute(self, query, args=None):
161166
try:
162167
r = None
163168
r = self._query(query)
164-
except TypeError, m:
169+
except TypeError as m:
165170
if m.args[0] in ("not enough arguments for format string",
166171
"not all arguments converted"):
167172
self.messages.append((ProgrammingError, m.args[0]))
@@ -212,7 +217,7 @@ def executemany(self, query, args):
212217
qv = m.group(1)
213218
try:
214219
q = [ qv % db.literal(a) for a in args ]
215-
except TypeError, msg:
220+
except TypeError as msg:
216221
if msg.args[0] in ("not enough arguments for format string",
217222
"not all arguments converted"):
218223
self.errorhandler(self, ProgrammingError, msg.args[0])
@@ -365,7 +370,7 @@ def scroll(self, value, mode='relative'):
365370
r = value
366371
else:
367372
self.errorhandler(self, ProgrammingError,
368-
"unknown scroll mode %s" % `mode`)
373+
"unknown scroll mode %s" % repr(mode))
369374
if r < 0 or r >= len(self._rows):
370375
self.errorhandler(self, IndexError, "out of range")
371376
self.rownumber = r

‎MySQLdb/_mysql.c

Copy file name to clipboardExpand all lines: MySQLdb/_mysql.c
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,8 +2979,8 @@ init_mysql(void)
29792979
if (!module) return; /* this really should never happen */
29802980
#endif
29812981
#ifdef IS_PY3K
2982-
/* Py_TYPE(_mysql_ConnectionObject_Type) = &PyType_Type;
2983-
Py_TYPE(_mysql_ResultObject_Type) = &PyType_Type; */
2982+
Py_TYPE(&_mysql_ConnectionObject_Type) = &PyType_Type;
2983+
Py_TYPE(&_mysql_ResultObject_Type) = &PyType_Type;
29842984
#else
29852985
_mysql_ConnectionObject_Type.ob_type = &PyType_Type;
29862986
_mysql_ResultObject_Type.ob_type = &PyType_Type;

‎MySQLdb/tests/dbapi20.py

Copy file name to clipboardExpand all lines: MySQLdb/tests/dbapi20.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ def help_nextset_setUp(self,cur):
706706
that returns two result sets, first the
707707
number of rows in booze then "name from booze"
708708
'''
709-
raise NotImplementedError,'Helper not implemented'
709+
raise NotImplementedError('Helper not implemented')
710710
#sql="""
711711
# create procedure deleteme as
712712
# begin
@@ -718,7 +718,7 @@ def help_nextset_setUp(self,cur):
718718

719719
def help_nextset_tearDown(self,cur):
720720
'If cleaning up is needed after nextSetTest'
721-
raise NotImplementedError,'Helper not implemented'
721+
raise NotImplementedError('Helper not implemented')
722722
#cur.execute("drop procedure deleteme")
723723

724724
def test_nextset(self):
@@ -751,7 +751,7 @@ def test_nextset(self):
751751
con.close()
752752

753753
def test_nextset(self):
754-
raise NotImplementedError,'Drivers need to override this test'
754+
raise NotImplementedError('Drivers need to override this test')
755755

756756
def test_arraysize(self):
757757
# Not much here - rest of the tests for this are in test_fetchmany
@@ -786,7 +786,7 @@ def test_setoutputsize_basic(self):
786786

787787
def test_setoutputsize(self):
788788
# Real test for setoutputsize is driver dependant
789-
raise NotImplementedError,'Driver need to override this test'
789+
raise NotImplementedError('Driver need to override this test')
790790

791791
def test_None(self):
792792
con = self._connect()

‎MySQLdb/tests/test_MySQLdb_capabilities.py

Copy file name to clipboardExpand all lines: MySQLdb/tests/test_MySQLdb_capabilities.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_bug_2671682(self):
7777
from MySQLdb.constants import ER
7878
try:
7979
self.cursor.execute("describe some_non_existent_table");
80-
except self.connection.ProgrammingError as msg:
80+
except self.connection.ProgrammingError as (msg,):
8181
self.assertTrue(msg[0] == ER.NO_SUCH_TABLE)
8282

8383
def test_bug_3514287(self):

‎MySQLdb/tests/test_MySQLdb_dbapi20.py

Copy file name to clipboardExpand all lines: MySQLdb/tests/test_MySQLdb_dbapi20.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,4 +203,3 @@ def test_nextset(self):
203203

204204
if __name__ == '__main__':
205205
unittest.main()
206-
print '''"Huh-huh, he said 'unit'." -- Butthead'''

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.