diff --git a/MySQLdb/MySQLdb/__init__.py b/MySQLdb/MySQLdb/__init__.py index 75092ad..8761671 100644 --- a/MySQLdb/MySQLdb/__init__.py +++ b/MySQLdb/MySQLdb/__init__.py @@ -77,7 +77,7 @@ def Binary(x): def Connect(*args, **kwargs): """Factory function for connections.Connection.""" - from connections import Connection + from MySQLdb.connections import Connection return Connection(*args, **kwargs) connect = Connection = Connect diff --git a/MySQLdb/MySQLdb/connections.py b/MySQLdb/MySQLdb/connections.py index 2b60311..427036a 100644 --- a/MySQLdb/MySQLdb/connections.py +++ b/MySQLdb/MySQLdb/connections.py @@ -6,7 +6,7 @@ want to make your own subclasses. In most cases, you will probably override Connection.default_cursor with a non-standard Cursor class. """ -import cursors +from MySQLdb import cursors from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \ DatabaseError, OperationalError, IntegrityError, InternalError, \ NotSupportedError, ProgrammingError @@ -33,7 +33,7 @@ def defaulterrorhandler(connection, cursor, errorclass, errorvalue): connection.messages.append(error) del cursor del connection - raise errorclass, errorvalue + raise errorclass(errorvalue) re_numeric_part = re.compile(r"^(\d+)") @@ -143,8 +143,8 @@ class Connection(_mysql.connection): documentation for the MySQL C API for some hints on what they do. """ - from constants import CLIENT, FIELD_TYPE - from converters import conversions + from MySQLdb.constants import CLIENT, FIELD_TYPE + from MySQLdb.converters import conversions from weakref import proxy, WeakValueDictionary import types diff --git a/MySQLdb/MySQLdb/converters.py b/MySQLdb/MySQLdb/converters.py index fbc24a1..cda1db8 100644 --- a/MySQLdb/MySQLdb/converters.py +++ b/MySQLdb/MySQLdb/converters.py @@ -33,8 +33,8 @@ MySQL.connect(). """ from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL -from constants import FIELD_TYPE, FLAG -from times import * +from MySQLdb.constants import FIELD_TYPE, FLAG +from MySQLdb.times import * import types import array diff --git a/MySQLdb/MySQLdb/cursors.py b/MySQLdb/MySQLdb/cursors.py index edf486a..53960ae 100644 --- a/MySQLdb/MySQLdb/cursors.py +++ b/MySQLdb/MySQLdb/cursors.py @@ -7,8 +7,13 @@ default, MySQLdb uses the Cursor class. import re import sys -from types import ListType, TupleType, UnicodeType - +try: + from types import ListType, TupleType, UnicodeType +except ImportError: + # Python 3 + ListType = list + TupleType = tuple + UnicodeType = str restr = (r"\svalues\s*" r"(\(((?= len(self._rows): self.errorhandler(self, IndexError, "out of range") self.rownumber = r diff --git a/MySQLdb/_mysql.c b/MySQLdb/_mysql.c index 5d59f34..63e990f 100644 --- a/MySQLdb/_mysql.c +++ b/MySQLdb/_mysql.c @@ -2979,8 +2979,8 @@ init_mysql(void) if (!module) return; /* this really should never happen */ #endif #ifdef IS_PY3K -/* Py_TYPE(_mysql_ConnectionObject_Type) = &PyType_Type; - Py_TYPE(_mysql_ResultObject_Type) = &PyType_Type; */ + Py_TYPE(&_mysql_ConnectionObject_Type) = &PyType_Type; + Py_TYPE(&_mysql_ResultObject_Type) = &PyType_Type; #else _mysql_ConnectionObject_Type.ob_type = &PyType_Type; _mysql_ResultObject_Type.ob_type = &PyType_Type; diff --git a/MySQLdb/tests/dbapi20.py b/MySQLdb/tests/dbapi20.py index a419e34..ad292ae 100644 --- a/MySQLdb/tests/dbapi20.py +++ b/MySQLdb/tests/dbapi20.py @@ -706,7 +706,7 @@ class DatabaseAPI20Test(unittest.TestCase): that returns two result sets, first the number of rows in booze then "name from booze" ''' - raise NotImplementedError,'Helper not implemented' + raise NotImplementedError('Helper not implemented') #sql=""" # create procedure deleteme as # begin @@ -718,7 +718,7 @@ class DatabaseAPI20Test(unittest.TestCase): def help_nextset_tearDown(self,cur): 'If cleaning up is needed after nextSetTest' - raise NotImplementedError,'Helper not implemented' + raise NotImplementedError('Helper not implemented') #cur.execute("drop procedure deleteme") def test_nextset(self): @@ -751,7 +751,7 @@ class DatabaseAPI20Test(unittest.TestCase): con.close() def test_nextset(self): - raise NotImplementedError,'Drivers need to override this test' + raise NotImplementedError('Drivers need to override this test') def test_arraysize(self): # Not much here - rest of the tests for this are in test_fetchmany @@ -786,7 +786,7 @@ class DatabaseAPI20Test(unittest.TestCase): def test_setoutputsize(self): # Real test for setoutputsize is driver dependant - raise NotImplementedError,'Driver need to override this test' + raise NotImplementedError('Driver need to override this test') def test_None(self): con = self._connect() diff --git a/MySQLdb/tests/test_MySQLdb_capabilities.py b/MySQLdb/tests/test_MySQLdb_capabilities.py index a42c95c..a8f144a 100644 --- a/MySQLdb/tests/test_MySQLdb_capabilities.py +++ b/MySQLdb/tests/test_MySQLdb_capabilities.py @@ -77,7 +77,7 @@ class test_MySQLdb(capabilities.DatabaseTest): from MySQLdb.constants import ER try: self.cursor.execute("describe some_non_existent_table"); - except self.connection.ProgrammingError as msg: + except self.connection.ProgrammingError as (msg,): self.assertTrue(msg[0] == ER.NO_SUCH_TABLE) def test_bug_3514287(self): diff --git a/MySQLdb/tests/test_MySQLdb_dbapi20.py b/MySQLdb/tests/test_MySQLdb_dbapi20.py index 5d1372b..4f4527a 100644 --- a/MySQLdb/tests/test_MySQLdb_dbapi20.py +++ b/MySQLdb/tests/test_MySQLdb_dbapi20.py @@ -203,4 +203,3 @@ class test_MySQLdb(dbapi20.DatabaseAPI20Test): if __name__ == '__main__': unittest.main() - print '''"Huh-huh, he said 'unit'." -- Butthead'''