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 5d91470

Browse filesBrowse files
committed
Merge pull request PyMySQL#68 from angieellis/master
PY3: Warning should be str
2 parents 22455e5 + ae99670 commit 5d91470
Copy full SHA for 5d91470

File tree

Expand file treeCollapse file tree

1 file changed

+14
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-11
lines changed

‎MySQLdb/cursors.py

Copy file name to clipboardExpand all lines: MySQLdb/cursors.py
+14-11Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
class BaseCursor(object):
4747
"""A base for Cursor classes. Useful attributes:
48-
48+
4949
description
5050
A tuple of DB API 7-tuples describing the columns in
5151
the last executed query; see PEP-249 for details.
@@ -55,20 +55,20 @@ class BaseCursor(object):
5555
in the result set. Values correspond to those in
5656
MySQLdb.constants.FLAG. See MySQL documentation (C API)
5757
for more information. Non-standard extension.
58-
58+
5959
arraysize
6060
default number of rows fetchmany() will fetch
6161
"""
6262

6363
from _mysql_exceptions import MySQLError, Warning, Error, InterfaceError, \
6464
DatabaseError, DataError, OperationalError, IntegrityError, \
6565
InternalError, ProgrammingError, NotSupportedError
66-
66+
6767
_defer_warnings = False
68-
68+
6969
def __init__(self, connection):
7070
from weakref import ref
71-
71+
7272
self.connection = ref(connection)
7373
self.description = None
7474
self.description_flags = None
@@ -82,7 +82,7 @@ def __init__(self, connection):
8282
self._warnings = 0
8383
self._info = None
8484
self.rownumber = None
85-
85+
8686
def close(self):
8787
"""Close the cursor. No further queries will be possible."""
8888
try:
@@ -124,7 +124,10 @@ def _warning_check(self):
124124
for w in warnings:
125125
self.messages.append((self.Warning, w))
126126
for w in warnings:
127-
warn(w[-1], self.Warning, 3)
127+
msg = w[-1]
128+
if not PY2 and isinstance(msg, bytes):
129+
msg = msg.decode()
130+
warn(msg, self.Warning, 3)
128131
elif self._info:
129132
self.messages.append((self.Warning, self._info))
130133
warn(self._info, self.Warning, 3)
@@ -159,10 +162,10 @@ def _do_get_result(self):
159162
self.lastrowid = db.insert_id()
160163
self._warnings = db.warning_count()
161164
self._info = db.info()
162-
165+
163166
def setinputsizes(self, *args):
164167
"""Does nothing, required by DB API."""
165-
168+
166169
def setoutputsizes(self, *args):
167170
"""Does nothing, required by DB API."""
168171

@@ -173,10 +176,10 @@ def _get_db(self):
173176
if con is None:
174177
raise ProgrammingError("cursor closed")
175178
return con
176-
179+
177180
def execute(self, query, args=None):
178181
"""Execute a query.
179-
182+
180183
query -- string, query to execute on server
181184
args -- optional sequence or mapping, parameters to use with query.
182185

0 commit comments

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