]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Patches to address SF bugs 1409538 (Japanese codecs in CODEC_MAP) and 1409455
authorBarry Warsaw <barry@python.org>
Wed, 8 Feb 2006 13:33:20 +0000 (13:33 +0000)
committerBarry Warsaw <barry@python.org>
Wed, 8 Feb 2006 13:33:20 +0000 (13:33 +0000)
commitf5853f7592fac39e7f6d0bccc0884b666b9edd99
tree88da931d569e40bf5994bd2fdd8154a501eee024
parent784fccf8100fac90772d3823757c56a74ea0f3e5
Patches to address SF bugs 1409538 (Japanese codecs in CODEC_MAP) and 1409455
(.set_payload() gives bad .get_payload() results).  Specific changes include:

Simplfy the default CODEC_MAP in Charset.py to not include the Japanese and
Korean codecs.  The names of the codecs are different depending on whether
you're using Python 2.4 and 2.5, which include the codecs by default, or
earlier Python's which provide the codecs under different names as a third
party library.  Now, we attempt to discover which (if either) is available and
populate the CODEC_MAP as appropriate.

Message.set_charset(): When the message does not already have a
Content-Transfer-Encoding header, instead of just adding the header, we also
encode the body as defined by the assigned Charset.  As before, if the
body_encoding is callable, we just call that.  If not, then we add a call to
body_encode() before setting the header.  This way, we guarantee that a
message's text payload is always encoded properly.

Remove the payload encoding code from Generator._handle_text().  With the
above patch, this would cause the body to be doubly encoded.  Doing this in
the Message class is better than only doing it in the Generator.

Added some new tests to ensure everything works correctly.  Also changed the
way the test_email_codecs.py tests get added (using the same lookup code that
the CODEC_MAP adjustments use).

This resolves both issues for email 2.5/Python 2.3.  I will patch forward to
email 3.0 for both Python 2.4 and 2.5.
Lib/email/Charset.py
Lib/email/Generator.py
Lib/email/Message.py
Lib/email/test/test_email.py
Lib/email/test/test_email_codecs.py