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 doko
Recipients barry, doko, r.david.murray
Date 2017-08-31.10:29:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1504175392.51.0.871887341171.issue31314@psf.upfronthosting.co.za>
In-reply-to
Content
[forwarded from https://bugs.debian.org/854001]

$ cat tst.py
#!/usr/bin/env python
import sys
import email

mail = email.message_from_string(
"""From: <postmaster@example.com>
To: <bounce@example.com>
Subject: demo
X-Overlong-Header-Name-causes-python-mail-to-crash-in-re-serialization-example:

Hello
""")
message = mail.as_string()
sys.stdout.write(message)

$ python tst.py 
Traceback (most recent call last):
  File "tst.py", line 13, in <module>
    message = mail.as_string()
  File "/usr/lib/python2.7/email/message.py", line 137, in as_string
    g.flatten(self, unixfrom=unixfrom)
  File "/usr/lib/python2.7/email/generator.py", line 83, in flatten
    self._write(msg)
  File "/usr/lib/python2.7/email/generator.py", line 115, in _write
    self._write_headers(msg)
  File "/usr/lib/python2.7/email/generator.py", line 164, in _write_headers
    v, maxlinelen=self._maxheaderlen, header_name=h).encode()
  File "/usr/lib/python2.7/email/header.py", line 408, in encode
    lastchunk, lastcharset = newchunks[-1]
IndexError: list index out of range
History
Date User Action Args
2017-08-31 10:29:52dokosetrecipients: + doko, barry, r.david.murray
2017-08-31 10:29:52dokosetmessageid: <1504175392.51.0.871887341171.issue31314@psf.upfronthosting.co.za>
2017-08-31 10:29:52dokolinkissue31314 messages
2017-08-31 10:29:51dokocreate