? email/Encoders.py.patch Index: email/Charset.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Charset.py,v retrieving revision 1.13 diff -u -r1.13 Charset.py --- email/Charset.py 6 Mar 2003 05:16:29 -0000 1.13 +++ email/Charset.py 30 Sep 2003 23:46:04 -0000 @@ -266,7 +266,11 @@ def convert(self, s): """Convert a string from the input_codec to the output_codec.""" if self.input_codec <> self.output_codec: - return unicode(s, self.input_codec).encode(self.output_codec) + # By replacing we may get unreadable characters. + # Should we make it chosable ? fail/replace (TK) + if not _isunicode(s): + s = unicode(s, self.input_codec, 'replace') + return s.encode(self.output_codec, 'replace') else: return s Index: email/Encoders.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/email/Encoders.py,v retrieving revision 1.7 diff -u -r1.7 Encoders.py --- email/Encoders.py 1 Oct 2002 00:05:24 -0000 1.7 +++ email/Encoders.py 30 Sep 2003 23:46:04 -0000 @@ -84,7 +84,12 @@ try: orig.encode('ascii') except UnicodeError: - msg['Content-Transfer-Encoding'] = '8bit' + # 'iso-2022-??' is non-ascii but '7bit' + charset = msg.get_charset().output_charset.lower() + if charset.startswith('iso-2022-'): + msg['Content-Transfer-Encoding'] = '7bit' + else: + msg['Content-Transfer-Encoding'] = '8bit' else: msg['Content-Transfer-Encoding'] = '7bit'