With simple example we get "UnicodeDecodeError: 'utf8' codec can't decode" error when reading email content.
See message in Forum "UnicodeDecodeError: 'utf8' codec can't decode" for further information
Logged In: YES
Hi. I can't seem to find your forum message -- can you attach an example or something that might help me debug the problem here, on the bug? Thanks.
Logged In: YES
I get an error very similar to this when attempting to get an attachment's contents, probably related.
sentfrom = 0
ga = libgmail.GmailAccount('firstname.lastname@example.org', 'pass')
folder = ga.getUnreadMessages()
for thread in folder:
for msg in thread:
for attachment in msg.attachments:
f=open('/tmp/' + attachment.filename, "wb")
print "attempting to write out attachment to /tmp/" + attachment.filename
pbot@haxit ~/code $ ./test.py
attempting to write out attachment to /tmp/photo.jpg
Traceback (most recent call last):
File "./test.py", line 19, in <module>
File "./test.py", line 15, in checkmail
File "/usr/lib64/python2.5/site-packages/libgmail.py", line 1507, in _getContent
File "/usr/lib64/python2.5/site-packages/libgmail.py", line 358, in _retrievePage
File "/usr/lib64/python2.5/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xff in position 0: unexpected code byte
I tried using the latest release and the latest cvs, both give the same error.
I had this same issue. I solved it by replacing "return pageData.decode("utf-8")" in libgmail.py with "return pageData". In other words, don't convert some binary file to a unicode string...
Fixed in CVS. Please check out the latest version; if it still doesn't work for you there, let us know.