python-wordpress-xmlrpc
python-wordpress-xmlrpc copied to clipboard
UnicodeDecodeError on printing comments with unicode in them
Whenever you retrieve or create a comment with valid unicode content, the __repr__
method fails on decoding. Seems like it's trying to convert what happens to be a unicode (or ASCII?) string encoded as string, then decoded to UTF. It's only an issue because when I try to print the returned list of Comments from a request, I get the error.
To reproduce:
new_comment = WordPressComment({'content':"\xa0"})
print new_comment
>>> *** UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position 0: ordinal not in range(128)
I think it's the equivalent of doing
print str(u'\xa0')
#or
unicode('\xa0')
But I'm not really familiar with this sort of thing so this could very well be a bad idea, but is it maybe worth trying to use unicode(self)
instead of the str(self).encode('utf-8')
?
I have the same problem when retriving posts with norwegian æøå in their titles. If i try to print, i get the same error as tankorsmash.
Cheers Bonsak
Same happens here when trying to print GetPosts.