Open wesinator opened 5 years ago
yea, I have got same exception, and its sad that the raised Exception breaks the generator, so it cannot be properly handled.
What about just returning raw msg in such cases, so generator can be consumed to exhaustion
or maybe this also fixes broader range of cases
def decode_content(message):
content = message.get_payload(decode=True)
charset = message.get_content_charset('utf-8')
try:
return content.decode(charset, 'ignore')
except LookupError:
import chardet
encoding = chardet.detect(content).get('encoding')
if encoding:
return content.decode(encoding, 'ignore')
return content
except AttributeError:
return content
Related: https://github.com/martinrusev/imbox/issues/177
@py-radicz Can you maybe submit a PR request and I will merge it into master. My only issue with the code above is to move the import chardet
bit to the top of the file
thats great idea to practice the PR since I have never done that. Will do.
Getting the same error on "windows-874" encoding w/latest pip install of this package Any workaround, @martinrusev ?
I tried @py-radicz 's solution.. no luck either
Email: imbox_lookuperror_unknown_encoding.eml.txt