[issue10790] Header.append's charset logic is bogus, 'shift_jis' and "euc_jp' don't work as charsets

R. David Murray report at bugs.python.org
Wed Dec 29 19:38:23 CET 2010


New submission from R. David Murray <rdmurray at bitdance.com>:

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.

----------
assignee: r.david.murray
files: header_append.patch
keywords: patch
messages: 124865
nosy: r.david.murray
priority: normal
severity: normal
stage: patch review
status: open
title: Header.append's charset logic is bogus, 'shift_jis' and "euc_jp' don't work as charsets
type: behavior
versions: Python 3.1, Python 3.2
Added file: http://bugs.python.org/file20188/header_append.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10790>
_______________________________________


More information about the Python-bugs-list mailing list