python-wordpress-xmlrpc icon indicating copy to clipboard operation
python-wordpress-xmlrpc copied to clipboard

While test client.call(GetPosts()), it throws UnicodeEncodeError if post's title is unicode text

Open rfancn opened this issue 9 years ago • 3 comments

File "", line 1, in File "/usr/lib/python2.6/site-packages/wordpress_xmlrpc/wordpress.py", line 51, in repr return '<%s: %s>' % (self.class.name, str(self).encode('utf-8')) UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-11: ordinal not in range(128)

rfancn avatar Nov 25 '15 10:11 rfancn

I found a workaround to change the line 54 of file "/usr/lib/python2.6/site-packages/wordpress_xmlrpc/wordpress.py" as below:

FROM: return '<%s: %s>' % (self.class.name, str(self).encode('utf-8')) TO: return '<%s: %s>' % (self.class.name, unicode(self).encode('utf-8'))

rfancn avatar Nov 25 '15 10:11 rfancn

return '<%s: %s>' % (self.class.name, self.str().encode('utf-8'))

worked for me

andiwand avatar Jan 12 '16 15:01 andiwand

FROM: return '<%s: %s>' % (self.class.name, str(self).encode('utf-8')) TO: return '<%s: %s>' % (self.class.name, unicode(self))

worked for me.

Animatr avatar Nov 21 '20 19:11 Animatr