New submission from Tim Koopman <python....@nandoe.net>:

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.

----------
components: Library (Lib)
files: header.patch
keywords: patch
messages: 137480
nosy: ntkoopman
priority: normal
severity: normal
status: open
title: email.header.Header encoding fails on empty header
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file22221/header.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12241>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to