From 0eb75d9c7e2db9e8ba439ee406ab3d6c32fc379e Mon Sep 17 00:00:00 2001 From: Andrew Engelbrecht Date: Tue, 21 Jul 2015 13:23:28 -0400 Subject: [PATCH] don't crash if a byte string can't be decoded --- edward | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/edward b/edward index e706c46..8f373a4 100755 --- a/edward +++ b/edward @@ -210,12 +210,14 @@ def get_subpart_data (part): obj.charset = 'utf-8' if obj.payload_bytes != None: - # this belongs in a specific try statement. - payload = PayloadPiece() - payload.string = obj.payload_bytes.decode(obj.charset) - payload.piece_type = 'text' + try: + payload = PayloadPiece() + payload.string = obj.payload_bytes.decode(obj.charset) + payload.piece_type = 'text' - obj.payload_pieces = [payload] + obj.payload_pieces = [payload] + except UnicodeDecodeError: + pass return obj -- 2.25.1