diff options
Diffstat (limited to 'logilab/common/umessage.py')
-rw-r--r-- | logilab/common/umessage.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/logilab/common/umessage.py b/logilab/common/umessage.py index a0394bc..e5a7f4e 100644 --- a/logilab/common/umessage.py +++ b/logilab/common/umessage.py @@ -27,8 +27,6 @@ from email.header import decode_header from datetime import datetime -from six import text_type, binary_type - try: from mx.DateTime import DateTime except ImportError: @@ -46,9 +44,9 @@ def decode_QP(string): # the 'official' fix is to use the new 'policy' APIs # https://bugs.python.org/issue24797 # let's just handle this bug ourselves for now - if isinstance(decoded, binary_type): + if isinstance(decoded, bytes): decoded = decoded.decode(charset, 'replace') - assert isinstance(decoded, text_type) + assert isinstance(decoded, str) parts.append(decoded) if sys.version_info < (3, 3): @@ -109,29 +107,29 @@ class UMessage: return [UMessage(msg) for msg in payload] if message.get_content_maintype() != 'text': return payload - if isinstance(payload, text_type): + if isinstance(payload, str): return payload charset = message.get_content_charset() or 'iso-8859-1' if search_function(charset) is None: charset = 'iso-8859-1' - return text_type(payload or b'', charset, "replace") + return str(payload or b'', charset, "replace") else: payload = UMessage(message.get_payload(index, decode)) return payload def get_content_maintype(self): - return text_type(self.message.get_content_maintype()) + return str(self.message.get_content_maintype()) def get_content_type(self): - return text_type(self.message.get_content_type()) + return str(self.message.get_content_type()) def get_filename(self, failobj=None): value = self.message.get_filename(failobj) if value is failobj: return value try: - return text_type(value) + return str(value) except UnicodeDecodeError: return u'error decoding filename' |