Author maxking
Recipients barry, maxking, r.david.murray, terry.reedy
Date 2019-07-09.18:11:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I just wanted to report before I forgot and hence missed some details, turns out the bug report was slightly wrong too. The testcase I provided wasn't right.

Here is the right test case to reproduce the exception with master:

from email.parser import BytesParser, Parser
from email.policy import default

payload = 'Content-Type:"'
msg = Parser(policy=default).parsestr(payload)

$ ./python                                                                                                                                                              
Traceback (most recent call last):
  File "", line 5, in <module>
    msg = Parser(policy=default).parsestr(payload)
  File "/home/maxking/Documents/cpython/Lib/email/", line 68, in parsestr
    return self.parse(StringIO(text), headersonly=headersonly)
  File "/home/maxking/Documents/cpython/Lib/email/", line 58, in parse
    return feedparser.close()
  File "/home/maxking/Documents/cpython/Lib/email/", line 187, in close
  File "/home/maxking/Documents/cpython/Lib/email/", line 180, in _call_parse
  File "/home/maxking/Documents/cpython/Lib/email/", line 256, in _parsegen
    if self._cur.get_content_type() == 'message/delivery-status':
  File "/home/maxking/Documents/cpython/Lib/email/", line 578, in get_content_type
    value = self.get('content-type', missing)
  File "/home/maxking/Documents/cpython/Lib/email/", line 471, in get
    return self.policy.header_fetch_parse(k, v)
  File "/home/maxking/Documents/cpython/Lib/email/", line 163, in header_fetch_parse
    return self.header_factory(name, value)
  File "/home/maxking/Documents/cpython/Lib/email/", line 602, in __call__
    return self[name](name, value)
  File "/home/maxking/Documents/cpython/Lib/email/", line 197, in __new__
    cls.parse(value, kwds)
  File "/home/maxking/Documents/cpython/Lib/email/", line 447, in parse
    kwds['decoded'] = str(parse_tree)
  File "/home/maxking/Documents/cpython/Lib/email/", line 126, in __str__
    return ''.join(str(x) for x in self)
  File "/home/maxking/Documents/cpython/Lib/email/", line 126, in <genexpr>
    return ''.join(str(x) for x in self)
  File "/home/maxking/Documents/cpython/Lib/email/", line 796, in __str__
    for name, value in self.params:
  File "/home/maxking/Documents/cpython/Lib/email/", line 770, in params
    value = param.param_value
  File "/home/maxking/Documents/cpython/Lib/email/", line 679, in param_value
    return token.stripped_value
  File "/home/maxking/Documents/cpython/Lib/email/", line 710, in stripped_value
    token = self[0]
IndexError: list index out of range

This time I attached a correct patch instead of copy-pasting only the diff :)

About IndexError, I agree, it must be an empty string value and not a None value.
Date User Action Args
2019-07-09 18:11:10maxkingsetrecipients: + maxking, barry, terry.reedy, r.david.murray
2019-07-09 18:11:10maxkingsetmessageid: <>
2019-07-09 18:11:10maxkinglinkissue37491 messages
2019-07-09 18:11:09maxkingcreate