From d87c3078783074c7c5f0950ba857931fd142575c Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 13 May 2017 14:54:49 +0300 Subject: [PATCH] Fix(Python2): Do not decode bytes to unicode --- mimedecode.py | 2 +- test/expected/msg_10.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mimedecode.py b/mimedecode.py index 5d58333..3b1df3e 100755 --- a/mimedecode.py +++ b/mimedecode.py @@ -243,7 +243,7 @@ def decode_body(msg, s): return s outfile = open(filename, 'wb') - if charset and isinstance(s, bytes): + if charset and bytes is not str and isinstance(s, bytes): # Python3 s = s.decode(charset, "replace") if not isinstance(s, bytes): s = s.encode(g.default_encoding, "replace") diff --git a/test/expected/msg_10.txt b/test/expected/msg_10.txt index 01dab93..e59a81b 100644 --- a/test/expected/msg_10.txt +++ b/test/expected/msg_10.txt @@ -22,7 +22,7 @@ MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-MIME-Autoconverted: from iso-8859-1 to utf-8 by test id mimedecode.py -¡This is a Quoted Printable encoded message! +¡This is a Quoted Printable encoded message! --BOUNDARY -- 2.39.2