Closed
Description
The MySQLdb.converters
module mostly returns strs in Python 3 (which I think is correct), but it ends up calling into _mysql.string_literal
in some cases, which returns bytes instead. When escaping tuples this can lead to TypeErrors:
In [35]: sys.version
Out[35]: '3.6.0 (default, Dec 26 2016, 07:53:45) \n[GCC 6.2.0 20160901]'
In [36]: MySQLdb.version_info
Out[36]: (1, 3, 9, 'final', 1)
In [37]: MySQLdb.escape(('a',), MySQLdb.converters.conversions)
Traceback:
File "/home/jelle/ans/venv64/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-37-d4b2dd1db689>", line 1, in <module>
MySQLdb.escape(('a',), MySQLdb.converters.conversions)
File "/home/jelle/ans/venv64/lib/python3.6/site-packages/MySQLdb/converters.py", line 90, in quote_tuple
return "(%s)" % (','.join(escape_sequence(t, d)))
TypeError: sequence item 0: expected str instance, bytes found
Metadata
Metadata
Assignees
Labels
No labels