Skip to content
Closed
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
13 changes: 10 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
language: python
python:
- "2.6"
- "2.7"
- "pypy"
- 2.6
- 2.7
- pypy
- 3.3
- 3.4
matrix:
allow_failures:
- python: 3.3
- python: 3.4
fast_finish: true
install: python setup.py install
before_script: mysql -e 'create database mysqldb_test charset utf8;'
script: TESTDB=travis.cnf nosetests
8 changes: 8 additions & 0 deletions MySQLdb/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import sys

if sys.version_info[0] == 3:
unicode = str
unichr = chr
else:
unicode = unicode
unichr = unichr
13 changes: 9 additions & 4 deletions MySQLdb/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@

"""
from MySQLdb import cursors
from MySQLdb.compat import unicode
from _mysql_exceptions import Warning, Error, InterfaceError, DataError, \
DatabaseError, OperationalError, IntegrityError, InternalError, \
NotSupportedError, ProgrammingError
import types, _mysql
import _mysql
import re


Expand All @@ -33,7 +34,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 Expand Up @@ -229,8 +234,8 @@ def string_decoder(s):
self.converter[FIELD_TYPE.VARCHAR].append((None, string_decoder))
self.converter[FIELD_TYPE.BLOB].append((None, string_decoder))

self.encoders[types.StringType] = string_literal
self.encoders[types.UnicodeType] = unicode_literal
self.encoders[bytes] = string_literal
self.encoders[unicode] = unicode_literal
self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS
if self._transactional:
if autocommit is not None:
Expand Down
19 changes: 7 additions & 12 deletions MySQLdb/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@

import re
import sys
try:
from types import ListType, TupleType, UnicodeType
except ImportError:
# Python 3
ListType = list
TupleType = tuple
UnicodeType = str

restr = r"""

from MySQLdb.compat import unicode

restr = br"""
\s
values
\s*
Expand Down Expand Up @@ -188,7 +183,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 +242,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 Expand Up @@ -305,7 +300,7 @@ def callproc(self, procname, args=()):
q = "CALL %s(%s)" % (procname,
','.join(['@_%s_%d' % (procname, i)
for i in range(len(args))]))
if type(q) is UnicodeType:
if isinstance(q, unicode):
q = q.encode(db.unicode_literal.charset)
self._query(q)
self._executed = q
Expand Down
4 changes: 0 additions & 4 deletions MySQLdb/release.py

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ TODO
----

* A bugfix 1.2.4 release
* A 1.3.0 release that will support Python 2.7-3.3
* A 1.3.0 release that will support Python 2.7-3.4
* The 2.0 version is being renamed [moist][] and is heavily refactored.

Projects
Expand Down
Loading