lovelysystems / robotframework-imaplibrary

Mail Library for Robot Framework
29 stars 87 forks source link

UnicodeDecodeError: #31

Open willmiraglia opened 8 years ago

willmiraglia commented 8 years ago

On some emails I'm reading, I get a unicode error like below. Any ideas why or how I can fix?

20160210 10:22:17.647 : FAIL : UnicodeDecodeError: 'ascii' codec can't decode byte 0x97 in position 391: ordinal not in range(128)

The URL looks like this: https://d2.glip.net:20010/r?t=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ0b2tlbl9pZCI6MTQ1NTExNzAzNzUwOSwidHlwZSI6InNpZ25pbiIsInVpZCI6MTU5NzQ0MywiZW1haWwiOiJ3bTJAYm9yYXNpLmNvbSIsImlhdCI6MTQ1NTExNzAzNywiaXNzIjoiZDIuZ2xpcC5uZXQiLCJzdWIiOiJnbGlwIn0.srS3ufobJzfg1or1Om1utHaPgPFYNrPXi_vGiDK6q86exJ3WIYeW3sm0XkZrIycS3tKg3wuIb0ajhzJGsRxepg&invite_id=1455117037697&inviter_id=1589251&company_id=958465&activate=1&utm_campaign=email&utm_source=invite

RF CODE

@{links} Get Links From Email ${LATEST}
${emailurls} get length ${links}
run keyword if "${emailurls}" == "0" FAIL No Emails Found in inbox for user ${email}

: FOR ${link} IN @{links}
${status} run keyword and return status should not contain ${link} youtube #Skip youtube link Run keyword if "${status}" == "False" Continue for Loop
Run keyword if "${status}" == "True" set test variable ${inviteurl} ${link} LOG ${link}
Mark As Read

willmiraglia commented 8 years ago

Fixed this by setting the default encoding to UTF8 inside init.py

/Library/Python/2.7/site-packages/ImapLibrary/init.py

import sys reload(sys)
sys.setdefaultencoding('utf8’)

peterstory commented 8 years ago

@schwendinger Do you think it would be a good idea to make this the default? I can create a pull request, if that would be helpful.

peterstory commented 8 years ago

Oops, I just saw that Pull Request #11 already fixes this issue. I'll just use the diff to patch the source code, since this repo has been deprecated.