]> khamidou — GitHub mirrors - flanker.git/commitdiff
Subject wrapper should inherit from unicode, not str.
authorChristine Spang <christine@spang.cc>
Wed, 20 Nov 2013 04:41:57 +0000 (20:41 -0800)
committerChristine Spang <christine@spang.cc>
Wed, 20 Nov 2013 04:41:59 +0000 (20:41 -0800)
This wrapper is used in the implementation of clean_subject(). Since all
headers are returned as unicode objects, it will cause a
UnicodeDecodeError if the subject contains unicode and clean_subject()
is called.

flanker/mime/message/headers/wrappers.py

index 3ca694db2282c07675cf38aeec64c23461476a1d..5c5bb474ca432e7f56f4d5e923c48dfc48a26bae 100644 (file)
@@ -170,11 +170,11 @@ class MessageId(str):
                 yield cls(message_id)
 
 
-class Subject(str):
+class Subject(unicode):
     RE_RE = re.compile("((RE|FW|FWD|HA)([[]\d])*:\s*)*", re.I)
 
     def __new__(cls, *args, **kw):
-        return str.__new__(cls, *args, **kw)
+        return unicode.__new__(cls, *args, **kw)
 
     def strip_replies(self):
         return self.RE_RE.sub('', self)