martinrusev / imbox

Python IMAP for Human beings
MIT License
1.19k stars 190 forks source link

LookupError on most emails. #113

Open muddi900 opened 6 years ago

muddi900 commented 6 years ago

I am getting this error on every email:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:/Users/muddi/Google Drive/sheet python project/tracking.py", line 45, in <module>
    for uid, msg in uRead:
  File "c:\Users\muddi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imbox\__init__.py", line 57, in fetch_list
    yield (uid, self.fetch_by_uid(uid))
  File "c:\Users\muddi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imbox\__init__.py", line 48, in fetch_by_uid
    email_object = parse_email(raw_email, policy=self.parser_policy)
  File "c:\Users\muddi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imbox\parser.py", line 159, in parse_email
    content = decode_content(part)
  File "c:\Users\muddi\AppData\Local\Programs\Python\Python36-32\lib\site-packages\imbox\parser.py", line 122, in decode_content
    return content.decode(charset, 'ignore')
LookupError: unknown encoding: cp-850

uRead is a unread Imbox fetch_list. I am trying to iterate through it, but keep getting this error

martinrusev commented 6 years ago

Hi @muddi900, python encoding errors are extremely difficult to debug without at least a couple of strings as an example. Or a message will be ideal, like this one: https://github.com/martinrusev/imbox/blob/master/tests/8422.msg

And then we can add it to the test suite for future cases

https://github.com/martinrusev/imbox/blob/master/tests/parser_tests.py

muddi900 commented 6 years ago

FedEx Shipment 432550986965 Notification.txt

I do not know if outlook reencoded the test when I exported it, but this is the first time the error re-occurred since the last time.