diff --git a/Lib/email/message.py b/Lib/email/message.py --- a/Lib/email/message.py +++ b/Lib/email/message.py @@ -50,7 +50,7 @@ # strictly RFC 2045 (section 5.1) compliant, but it catches most headers # found in the wild. We may eventually need a full fledged parser # eventually. - a, sep, b = param.partition(';') + a, sep, b = str(param).partition(';') if not sep: return a.strip(), None return a.strip(), b.strip() @@ -241,7 +241,7 @@ if i is not None and not isinstance(self._payload, list): raise TypeError('Expected list, got %s' % type(self._payload)) payload = self._payload - cte = self.get('content-transfer-encoding', '').lower() + cte = str(self.get('content-transfer-encoding', '')).lower() # payload can be bytes here, (I wonder if that is actually a bug?) if isinstance(payload, str): if _has_surrogates(payload): @@ -562,7 +562,7 @@ if value is missing: return failobj params = [] - for p in _parseparam(';' + value): + for p in _parseparam(';' + str(value)): try: name, val = p.split('=', 1) name = name.strip()