[MERGE] An EmailMessage class for bzrlib (v3)

Martin Pool mbp at canonical.com
Tue Jul 10 05:49:48 BST 2007

Martin Pool has voted -0.
Status is now: Waiting
+        self._init_message(self, from_address, to_address, subject, 
+    @staticmethod
+    def _init_message(msg, from_address, to_address, subject, 

It does seem pretty strange to have a static method that takes (usually)
an instance of this class as its first parameter, and then switching on
isinstance within it is also a bad sign.  To me it looks like rather 
subclassing this type, we should have our own class which acts as a 
to one class or the other.

+    @staticmethod
+    def string_with_encoding(string):
+        """Return a str object together with an encoding.
+        :param string: A str or unicode object.
+        :return: A tuple (str, encoding), where encoding is one of 
+            'utf-8', or '8-bit', in that preferred order.

Having automatic behaviour depending on whether something is a unicode 
str object has been a bit problematic in the past.  Would it be feasible
to have different interfaces and insist on the caller knowing whether
they're putting in binary, ascii or unicode data?

Also it would be good if the docstring explained more about _why_ you
would call this method - it's meant to guess the right encoding to use 
sending this file.

For details, see: 

More information about the bazaar mailing list