diff options
| author | Barry Warsaw | 2014-12-18 11:50:27 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2014-12-18 11:50:27 -0500 |
| commit | b356a37b90cb725c2e1b9dcbc811ff528e3c8916 (patch) | |
| tree | d0b359775692fc06065eef7a3694c513b60010da /src/mailman/runners/digest.py | |
| parent | d53efd9675aba93ececf45952eb8df1286610e50 (diff) | |
| download | mailman-b356a37b90cb725c2e1b9dcbc811ff528e3c8916.tar.gz mailman-b356a37b90cb725c2e1b9dcbc811ff528e3c8916.tar.zst mailman-b356a37b90cb725c2e1b9dcbc811ff528e3c8916.zip | |
Diffstat (limited to 'src/mailman/runners/digest.py')
| -rw-r--r-- | src/mailman/runners/digest.py | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/mailman/runners/digest.py b/src/mailman/runners/digest.py index 1716d9694..f3b94841b 100644 --- a/src/mailman/runners/digest.py +++ b/src/mailman/runners/digest.py @@ -259,17 +259,16 @@ class RFC1153Digester(Digester): # multipart message. In that case, just stringify it. payload = msg.get_payload(decode=True) if not payload: - # Split using bytes so as not to turn the payload into unicode - # strings due to unicode_literals above. - payload = msg.as_string().split(b'\n\n', 1)[1] - try: - # Do the decoding inside the try/except so that if the charset - # conversion fails, we'll just drop back to ascii. - charset = msg.get_content_charset('us-ascii') - payload = payload.decode(charset, 'replace') - except (LookupError, TypeError): - # Unknown or empty charset. - payload = payload.decode('us-ascii', 'replace') + payload = msg.as_string().split('\n\n', 1)[1] + if isinstance(payload, bytes): + try: + # Do the decoding inside the try/except so that if the charset + # conversion fails, we'll just drop back to ascii. + charset = msg.get_content_charset('us-ascii') + payload = payload.decode(charset, 'replace') + except (LookupError, TypeError): + # Unknown or empty charset. + payload = payload.decode('us-ascii', 'replace') print(payload, file=self._text) if not payload.endswith('\n'): print(file=self._text) |
