Skip to content

'surrogates not allowed' error on stored procedure call for unicode argument #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jinto opened this issue Jun 7, 2016 · 3 comments
Closed

Comments

@jinto
Copy link
Contributor

jinto commented Jun 7, 2016

On python 3.5.1, mysqlclient 1.3.7

cursor.callproc() with unicode string argument generates error below
'utf-8' codec can't encode character '\udceb' in position 39: surrogates not allowed

The code works if I change below code

def literal(self, o): 
    s = self.escape(o, self.encoders)
    if not PY2 and isinstance(s, bytes):
        return s.decode('ascii', 'surrogateescape')
    return s

to

def literal(self, o): 
    s = self.escape(o, self.encoders)
    if not PY2 and isinstance(s, bytes):
        return s.decode('utf8', 'surrogateescape')
    return s

changes : 'ascii' to 'utf8'
ps. tested string was korean string, "제권".

@jinto
Copy link
Contributor Author

jinto commented Jun 8, 2016

I think problem was not in literal(), but in the callproc() after calling literal().

@methane methane closed this as completed Jun 28, 2016
@ghost
Copy link

ghost commented Apr 22, 2019

RuntimeWarning: Surrogate character '\ude46' will be ignored. You might be using a narrow Python build

can u tell me about above error??

@jinto
Copy link
Contributor Author

jinto commented Apr 24, 2019

It was fixed by #91 .
I cannot remember the details. I think this is closed 3 years ago.
If you are interested in the issue you can digg into the pr above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants