From: Oleg Broytman Date: Sat, 13 May 2017 11:54:49 +0000 (+0300) Subject: Fix(Python2): Do not decode bytes to unicode X-Git-Tag: 2.8.0~39 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=d87c3078783074c7c5f0950ba857931fd142575c;p=mimedecode.git Fix(Python2): Do not decode bytes to unicode --- 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