Merge pull request #8204 from ashish-greycube/patch-8

fix(email): AttributeError: 'Message' object has no attribute 'encode' #8148
This commit is contained in:
mergify[bot] 2019-08-21 08:20:12 +00:00 committed by GitHub
commit 005c1951b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -481,10 +481,7 @@ class Email:
"""Detect chartset."""
charset = part.get_content_charset()
if not charset:
if six.PY2:
charset = chardet.detect(str(part))['encoding']
else:
charset = chardet.detect(part.encode())['encoding']
charset = chardet.detect(frappe.safe_encode(part))['encoding']
return charset