classification
Title: Header.append's charset logic is bogus, 'shift_jis' and "euc_jp' don't work as charsets
Type: behavior Stage: resolved
Components: Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: barry, r.david.murray
Priority: normal Keywords: patch

Created on 2010-12-29 18:38 by r.david.murray, last changed 2011-01-05 01:48 by r.david.murray. This issue is now closed.

Files
File name Uploaded Description Edit
header_append.patch r.david.murray, 2010-12-29 18:38
header_append.patch r.david.murray, 2010-12-29 18:55
Messages (3)
msg124865 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-29 18:38
Working on issue 10686, I've discovered that the logic for charset conversion in email.header.Header.append is bogus.  It happens to work for most charsets because for most charsets the input codec and the output codec are the same.  For shift_jis and euc_jp, however, this is not the case.

The attached patch fixes the logic and provides a test.

The logic is still not quite correct, since the 'errors' parameter should not be passed to the 'encode' test call, because the errors parameter is not passed to the encode call when the actual encoding is done in the Header.encode method.  If that call were fixed in this patch, one of the email tests would fail that currently passes.  However, if a 'Header.encode' call were made in that test, the encode call would fail.  Fixing that will require resolving issue 10686.
msg124867 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-29 18:55
Updated patch that also fixes the docs.
msg125394 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-01-05 01:48
Committed to py3k in r87750 and 3.1 in r87751.
History
Date User Action Args
2011-01-05 01:48:48r.david.murraysetstatus: open -> closed

messages: + msg125394
resolution: fixed
stage: patch review -> resolved
2010-12-29 18:55:47r.david.murraysetfiles: + header_append.patch

messages: + msg124867
2010-12-29 18:42:44r.david.murraysetnosy: + barry
2010-12-29 18:38:17r.david.murraycreate