Pull_from_email_account

{'method': <function pull_from_email_account at 0x7fc5906d0950>, 'method_name': 'pull_from_email_account', 'site': 'site1.local', 'kwargs': {'email_account': 'Replies'}, 'user': 'Administrator', 'log': <function log at 0x7fc591167ea0>, 'async': True, 'retry': 0, 'job_name': 'pull_from_email_account|Replies', 'event': 'all'}
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 116, in get_messages
    uid_list = email_list = self.get_new_mails()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 176, in get_new_mails
    self.check_imap_uidvalidity()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 194, in check_imap_uidvalidity
    current_uid_validity = self.parse_imap_responce("UIDVALIDITY", message[0])
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 228, in parse_imap_responce
    match = re.search(pattern, responce, re.U | re.I)
  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

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/background_jobs.py", line 97, in execute_job
    method(**kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 707, in pull_from_email_account
    email_account.receive()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/doctype/email_account/email_account.py", line 258, in receive
    emails = email_server.get_messages()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 149, in get_messages
    if self.has_login_limit_exceeded(e):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/email/receive.py", line 295, in has_login_limit_exceeded
    return "-ERR Exceeded the login limit" in strip(cstr(e.message))
AttributeError: 'TypeError' object has no attribute 'message'

Hi @achillesrasquinha please perhaps you can respond -

Is say the regular expression string here not encoded correctly?

Fixed with this https://github.com/frappe/frappe/pull/5902

match = re.search(pattern, responce, re.U | re.I)

changed to

match = re.search(pattern, responce.decode(‘utf-8’), re.U | re.I)

1 Like