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 self._write(msg) File "/usr/lib64/python3.4/email/generator.py", line 192, in _write self._write_headers(msg) … File "/usr/lib64/python3.4/email/_header_value_parser.py", line 195, in <genexpr> return ''.join(str(x) for x in self) RuntimeError: maximum recursion depth exceeded while getting the str of an object 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> <http://bugs.python.org/issue22684> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com