diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2011-03-17 01:48:30 (GMT) |
---|---|---|
committer | Nick Coghlan <ncoghlan@gmail.com> | 2011-03-17 01:48:30 (GMT) |
commit | ce4ee1f34d89cc0606ed8c34dec09b4f315052d8 (patch) | |
tree | 1d14437bd77039a4bc895c57a0f5b44abf78ce80 /Lib/email/message.py | |
parent | 49cb9593a0ae4da35c44fa46636e4a11acd2581a (diff) | |
parent | a215023b784eb1e23b2e91a007bc9a19750ed3c0 (diff) | |
download | cpython-ce4ee1f34d89cc0606ed8c34dec09b4f315052d8.zip cpython-ce4ee1f34d89cc0606ed8c34dec09b4f315052d8.tar.gz cpython-ce4ee1f34d89cc0606ed8c34dec09b4f315052d8.tar.bz2 |
Merge from 3.2
Diffstat (limited to 'Lib/email/message.py')
-rw-r--r-- | Lib/email/message.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/email/message.py b/Lib/email/message.py index 2713bc5..922617a 100644 --- a/Lib/email/message.py +++ b/Lib/email/message.py @@ -48,9 +48,9 @@ def _sanitize_header(name, value): def _splitparam(param): # Split header parameters. BAW: this may be too simple. It isn't # 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(';') + # found in the wild. We may eventually need a full fledged parser. + # RDM: we might have a Header here; for now just stringify it. + a, sep, b = str(param).partition(';') if not sep: return a.strip(), None return a.strip(), b.strip() @@ -90,6 +90,8 @@ def _formatparam(param, value=None, quote=True): return param def _parseparam(s): + # RDM This might be a Header, so for now stringify it. + s = ';' + str(s) plist = [] while s[:1] == ';': s = s[1:] @@ -240,7 +242,8 @@ class Message: 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 might be a Header, so for now stringify it. + cte = str(self.get('content-transfer-encoding', '')).lower() # payload may be bytes here. if isinstance(payload, str): if _has_surrogates(payload): @@ -561,7 +564,7 @@ class Message: if value is missing: return failobj params = [] - for p in _parseparam(';' + value): + for p in _parseparam(value): try: name, val = p.split('=', 1) name = name.strip() |