Skip to content

UnicodeDecodeError on printing comments with unicode in them #42

@tankorsmash

Description

@tankorsmash

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') ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions