IMAP pull_from_email_account (encoding issue on unseen flag)

Recently the encoding issue for
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py”, line 243, in retrieve_message
self.get_email_seen_status(message_meta, raw[0])
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py”, line 286, in get_email_seen_status
match = re.search(pattern, flag)
File “/home/frappe/frappe-bench/env/lib/python3.5/re.py”, line 173, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object

I believe this is the fix needed…

apps/frappe/frappe/email/receive.py line 286

match = re.search(pattern, flag.decode(‘utf-8’))

I could be completely wrong but it seems to work :wink: