[ python-Bugs-826756 ] email/Generator.py: Incorrect header output

SourceForge.net noreply at sourceforge.net
Fri Nov 21 13:38:07 EST 2003

Bugs item #826756, was opened at 2003-10-20 06:23
Message generated for change (Comment added) made by bwarsaw
You can respond by visiting: 

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Matthias Pronk (mjepronk)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: email/Generator.py: Incorrect header output

Initial Comment:
I've found a small bug when using the email/Parser.py
classes. When there is a long "Subject" header, it will
be wrapped to multiple lines, which are preceded by a
tab. This is undesired behaviour, because e-mail
clients show this tab in the subject. Especially,
Mozilla for Windows shows a strange square symbol. The
following code in email/Generator.py (line 180)
resolves the problem:

                # Header's got lots of smarts, so use it.
                if h.lower() == 'subject':
                    cont_ws = ' ' 
                    cont_ws = '\t'
                print >> self._fp, Header(
                    v, maxlinelen=self.__maxheaderlen,

For more information you can e-mail me: matthias -at-


>Comment By: Barry A. Warsaw (bwarsaw)
Date: 2003-11-21 13:38

Logged In: YES 

RFC 2822 specifies when and how long headers are supposed to
be wrapped, and the default Generator behavior is to be
compliant with this standard.  I consider it a bug in your
mail reader that such long headers are displayed incorrectly
(other mail readers display long wrapped headers correctly).

Having said this, you have options.  You can disable
wrapping altogether by passing maxheaderlen=0 to the
Generator constructor, or you can create a Generator
subclass which overrides the _write_headers() method and
passes a different value for continuation_ws.


You can respond by visiting: 

More information about the Python-bugs-list mailing list