Skip to content

Commit c7d2168

Browse files
woojingmethane
authored andcommitted
add surrogate escape for callproc and test case for that (PyMySQL#104)
1 parent fb842fb commit c7d2168

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎MySQLdb/cursors.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def callproc(self, procname, args=()):
347347
q = "SET @_%s_%d=%s" % (procname, index,
348348
db.literal(arg))
349349
if isinstance(q, unicode):
350-
q = q.encode(db.unicode_literal.charset)
350+
q = q.encode(db.unicode_literal.charset, 'surrogateescape')
351351
self._query(q)
352352
self.nextset()
353353

‎tests/test_MySQLdb_capabilities.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
23
import capabilities
34
from datetime import timedelta
45
import unittest
@@ -43,7 +44,7 @@ def test_stored_procedures(self):
4344
c = self.cursor
4445
self.create_table(('pos INT', 'tree CHAR(20)'))
4546
c.executemany("INSERT INTO %s (pos,tree) VALUES (%%s,%%s)" % self.table,
46-
list(enumerate('ash birch cedar larch pine'.split())))
47+
list(enumerate('ash birch cedar Lärche pine'.split())))
4748
db.commit()
4849

4950
c.execute("""
@@ -54,7 +55,7 @@ def test_stored_procedures(self):
5455
""" % self.table)
5556
db.commit()
5657

57-
c.callproc('test_sp', ('larch',))
58+
c.callproc('test_sp', ('Lärche',))
5859
rows = c.fetchall()
5960
self.assertEqual(len(rows), 1)
6061
self.assertEqual(rows[0][0], 3)

0 commit comments

Comments
 (0)