robotframework-imaplibrary
robotframework-imaplibrary copied to clipboard
UnicodeDecodeError:
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
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’)
@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.
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.