[Bug 1800881] Re: mysqldb bytes error
Launchpad Bug Tracker
1800881 at bugs.launchpad.net
Thu Nov 1 06:22:14 UTC 2018
Status changed to 'Confirmed' because the bug affects multiple users.
** Changed in: python-mysqldb (Ubuntu)
Status: New => Confirmed
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to python-mysqldb in Ubuntu.
https://bugs.launchpad.net/bugs/1800881
Title:
mysqldb bytes error
Status in python-mysqldb package in Ubuntu:
Confirmed
Bug description:
The version of the library provided in the distribution contains an
error.
TypeError: a bytes-like object is required, not 'str'
This bug is fixed in the library version 1.3.13 or can be fixed by a
patch:
--- MySQLdb/cursors.py.orig
+++ MySQLdb/cursors.py
@@ -21,7 +21,17 @@
else:
text_type = str
-
+def convert_to_str(var):
+ if isinstance(var,tuple):
+ return tuple(convert_to_str(item) for item in var)
+ if isinstance(var,list):
+ return ([convert_to_str(item) for item in var])
+ elif isinstance(var,dict):
+ return {convert_to_str(key):convert_to_str(value) for key,value in var.items()}
+ elif isinstance(var,bytes):
+ return var.decode('utf-8')
+ else:
+ return var
#: Regular expression for :meth:`Cursor.executemany`.
#: executemany only supports simple bulk insert.
#: You can use it to load large dataset.
@@ -443,6 +453,9 @@
else:
result = self._rows
self.rownumber = len(self._rows)
+ if not PY2:
+ db = self._get_db()
+ result = tuple(convert_to_str(result))
return result
def scroll(self, value, mode='relative'):
Please upgrade version lib or apply this patch.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-mysqldb/+bug/1800881/+subscriptions
More information about the foundations-bugs
mailing list