From ee6ad1ccf4b19888df538faff8923511e33e4193 Mon Sep 17 00:00:00 2001 From: jay park Date: Thu, 9 Jun 2016 02:43:00 +0900 Subject: [PATCH] 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 . --- MySQLdb/cursors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MySQLdb/cursors.py b/MySQLdb/cursors.py index 1e0a3f9..75b9aee 100644 --- a/MySQLdb/cursors.py +++ b/MySQLdb/cursors.py @@ -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: