]> git.phdru.name Git - mimedecode.git/blobdiff - mimedecode.py
Different requirements for Py2 and Py3
[mimedecode.git] / mimedecode.py
index 839703fbc6d6b85d13145f2afc192b3145cbd454..64e2184e5b978bc3f70455fe360c98658a8d321a 100755 (executable)
@@ -35,7 +35,7 @@ def output_headers(msg):
 
 def recode_if_needed(s, charset):
     if charset and charset.lower() != g.default_encoding:
-        s = unicode(s, charset, "replace").encode(g.default_encoding, "replace")
+        s = s.decode(charset, "replace").encode(g.default_encoding, "replace")
     return s
 
 
@@ -43,9 +43,9 @@ def _decode_header(s):
     """Return a decoded string according to RFC 2047.
     NOTE: This is almost the same as email.Utils.decode.
     """
-    import email.Header
+    import email.header
 
-    L = email.Header.decode_header(s)
+    L = email.header.decode_header(s)
     if not isinstance(L, list):
         # s wasn't decoded
         return s