W. Trevor King added the comment:

Here's an example from the notmuch list.  You can trigger the exception in 
Python 3.4 with:

  >>> import email.policy
  >>> import mailbox
  >>> mbox = mailbox.mbox('msg.mbox', factory=None, create=False)
  >>> message = mbox[0]
  >>> message.as_bytes(policy=email.policy.SMTP)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/home/wking/src/notmuch/ssoma_mda.py", line 319, in deliver
      message_bytes = message.as_bytes(policy=_email_policy.SMTP)
    File "/usr/lib64/python3.4/email/message.py", line 179, in as_bytes
      g.flatten(self, unixfrom=unixfrom)
    File "/usr/lib64/python3.4/email/generator.py", line 112, in flatten
    File "/usr/lib64/python3.4/email/generator.py", line 192, in _write
    File "/usr/lib64/python3.4/email/_header_value_parser.py", line 195, in 
      return ''.join(str(x) for x in self)
  RuntimeError: maximum recursion depth exceeded while getting the str of an 

Interestingly, it serializes fine using the default policy:

  >>> message.as_bytes()
  b'Return-Path: …-----\n'

nosy: +labrat
Added file: http://bugs.python.org/file37143/msg.mbox

Python tracker <rep...@bugs.python.org>
Python-bugs-list mailing list

Reply via email to