This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ntkoopman
Recipients ntkoopman
Date 2011-06-02.15:25:13
SpamBayes Score 9.1421846e-08
Marked as misclassified No
Message-id <1307028314.79.0.859095515398.issue12241@psf.upfronthosting.co.za>
In-reply-to
Content
Creating an empty header produces an exception when calling the encode function:

>>> from email.header import Header
>>> Header('', 'iso-8859-1').encode()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.2/email/header.py", line 317, in encode
    formatter.feed(lines[0], charset)
IndexError: list index out of range

According to RFC822, empty headers are valid (and are found in the wild anyway), so this should just work.

I've attached a trivial fix that appears to work.
History
Date User Action Args
2011-06-02 15:25:14ntkoopmansetrecipients: + ntkoopman
2011-06-02 15:25:14ntkoopmansetmessageid: <1307028314.79.0.859095515398.issue12241@psf.upfronthosting.co.za>
2011-06-02 15:25:14ntkoopmanlinkissue12241 messages
2011-06-02 15:25:13ntkoopmancreate