unicode string in argument of string raises error

Hi, I've got  'surrogates not allowed' error when I put unicode string into stored procedure's argument.
This is pr for the issue.

cf: https://github.com/PyMySQL/mysqlclient-python/issues/90 .
This commit is contained in:
jay park
2016-06-09 02:43:00 +09:00
parent ae9d6f8ccb
commit ee6ad1ccf4

View File

@ -358,7 +358,7 @@ class BaseCursor(object):
','.join(['@_%s_%d' % (procname, i)
for i in range(len(args))]))
if isinstance(q, unicode):
q = q.encode(db.unicode_literal.charset)
q = q.encode(db.unicode_literal.charset, 'surrogateescape')
self._query(q)
self._executed = q
if not self._defer_warnings: