[New-bugs-announce] [issue16811] email.message.Message flatten dies of list index out of range
Helmut Jarausch
report at bugs.python.org
Sat Dec 29 11:23:14 CET 2012
New submission from Helmut Jarausch:
The following code triggers the bug:
#!/usr/bin/python3.3
#-*- coding: latin1 -*-
from email.message import Message
from email import policy
from email.parser import FeedParser
Parser= FeedParser(policy=policy.SMTP)
Parser.feed('From jarausch at igpm.rwth-aachen.de Tue Apr 24 15:09:24 2012\n')
Parser.feed('X-Status: \n') # this triggers the bug
Parser.feed('From: Helmut Jarausch <jarausch at igpm.rwth-aachen.de>\n')
Msg= Parser.close()
Msg_as_str= Msg.as_string(unixfrom=True)
This triggers
File "Email_Parse_Bug.py", line 13, in <module>
Msg_as_str= Msg.as_string(unixfrom=True)
File "/usr/lib64/python3.3/email/message.py", line 151, in as_string
g.flatten(self, unixfrom=unixfrom)
File "/usr/lib64/python3.3/email/generator.py", line 112, in flatten
self._write(msg)
File "/usr/lib64/python3.3/email/generator.py", line 171, in _write
self._write_headers(msg)
File "/usr/lib64/python3.3/email/generator.py", line 198, in _write_headers
self.write(self.policy.fold(h, v))
File "/usr/lib64/python3.3/email/policy.py", line 153, in fold
return self._fold(name, value, refold_binary=True)
File "/usr/lib64/python3.3/email/policy.py", line 176, in _fold
(len(lines[0])+len(name)+2 > maxlen or
IndexError: list index out of range
If I strip the '\n' from the lines feeded to the Parser,
the bug does not occur.
Thanks for looking into it,
Helmut.
This is with Python 3.3.0+ 3.3:ccc372b37fbb+
----------
components: Library (Lib)
messages: 178482
nosy: HJarausch
priority: normal
severity: normal
status: open
title: email.message.Message flatten dies of list index out of range
type: crash
versions: Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16811>
_______________________________________
More information about the New-bugs-announce
mailing list