[issue22684] message.as_bytes() produces recursion depth exceeded

2021-11-26 Thread Irit Katriel


Irit Katriel  added the comment:

I am unable to reproduce this on 3.11.

--
nosy: +iritkatriel
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22684] message.as_bytes() produces recursion depth exceeded

2015-10-19 Thread Jan Malte

Jan Malte added the comment:

for the same objects as_string() is working correctly

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22684] message.as_bytes() produces recursion depth exceeded

2015-10-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is minimized example.

from email._header_value_parser import *
al = 
AddressList([Address([Mailbox([NameAddr([DisplayName([Atom([ValueTerminal('example',
 'atext'), CFWSList([WhiteSpaceTerminal('\t', 'fws')])])]), 
AngleAddr([ValueTerminal('<', 'angle-addr-start'), 
AddrSpec([LocalPart([DotAtom([DotAtomText([ValueTerminal('very-very-very-very-very-very-very-very-very-very-very-very-long',
 'atext')])])]), ValueTerminal('@', 'address-at-symbol'), 
Domain([DotAtom([DotAtomText([ValueTerminal('example', 'atext'), 
ValueTerminal('.', 'dot'), ValueTerminal('org', 'atext')])])])]), 
ValueTerminal('>', 'angle-addr-end')])])])]), ValueTerminal(',', 
'list-separator'), 
Address([Mailbox([NameAddr([AngleAddr([CFWSList([WhiteSpaceTerminal('\t', 
'fws')]), ValueTerminal('<', 'angle-addr-start'), 
AddrSpec([LocalPart([DotAtom([DotAtomText([ValueTerminal('very-very-very-very-very-very-very-very-very-very-very-very-long',
 'atext')])])]), ValueTerminal('@', 'address-at-symbol'), 
Domain([DotAtom([DotAtomText([ValueTerminal('example', 'atext'), 
ValueTerminal('.', 'dot'), Val
 ueTerminal('org', 'atext')])])])]), ValueTerminal('>', 
'angle-addr-end')])])])])])
import email.policy
al.fold(policy=email.policy.default)

--
nosy: +serhiy.storchaka
Added file: http://bugs.python.org/file40814/msg.mbox

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22684] message.as_bytes() produces recursion depth exceeded

2015-10-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Even more minimized artificial example:

from email._header_value_parser import *
import email.policy
tl = TokenList([
TokenList([
ValueTerminal('x', 'atext'),
WhiteSpaceTerminal(' ', 'fws'),
ValueTerminal('x'*76, 'atext'),
]),
ValueTerminal(',', 'list-separator')
])
tl.fold(policy=email.policy.default)

list(tl.parts)[0] == tl and tl.has_fws is True, so TokenList._fold() is called 
recursively with the same argument.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22684] message.as_bytes() produces recursion depth exceeded

2015-10-13 Thread Jan Malte

Jan Malte added the comment:

Are there any news about this bug report?

--
nosy: +janmalte

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue22684] message.as_bytes() produces recursion depth exceeded

2014-11-07 Thread W. Trevor King

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



[issue22684] message.as_bytes() produces recursion depth exceeded

2014-11-07 Thread W. Trevor King

W. Trevor King added the comment:

The troublesome header formatting is:

   import email.policy
   email.policy.SMTP.fold_binary('Cc', 
'notmuch\n\tpublic-public-notmuch-gxuj+Tv9EO5zyzON3hdc1g-wOFGN7rlS/M9smdsby/k...@plane.gmane.org,\n\tpublic-notmuch-gxuj+tv9eo5zyzon3hd...@plane.gmane.org,\n\tRainer
 M Krug public-r.m.krug-re5jqeeqqe8avxtiumw...@plane.gmane.org,\n\tJeremy 
Nickurak\n\tpublic-public-not-much-kexSNQTsIoD754YsiR0rpA-wOFGN7rlS/M9smdsby/k...@plane.gmane.org')
  Traceback (most recent call last):
…
  RuntimeError: maximum recursion depth exceeded while getting the str of an 
object

Trimming that down a bit, a minimal trigger seems to be:

   email.policy.SMTP.fold_binary('Cc', 
'a\n\ta,\n\ta')
  Traceback…

Where removing much of anything gives a working fold.

--

___
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



[issue22684] message.as_bytes() produces recursion depth exceeded

2014-11-07 Thread W. Trevor King

W. Trevor King added the comment:

In email._header_value_parser._Folded.append_if_fits, if I shift:

if token.has_fws:
ws = token.pop_leading_fws()
if ws is not None:
self.stickyspace += str(ws)
stickyspace_len += len(ws)
token._fold(self)
return True

to:

if token.has_fws:
ws = token.pop_leading_fws()
if ws is not None:
self.stickyspace += str(ws)
stickyspace_len += len(ws)
token._fold(self)
return True

I can avoid the recursion.

The problem seems to be that the a …aaa token/part contains folding white 
space, but doesn't *start* with folding whitespace.  Maybe the folding should 
try to split on existing FWS, instead of just trying to pop leading FWS?

--

___
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



[issue22684] message.as_bytes() produces recursion depth exceeded

2014-11-07 Thread R. David Murray

R. David Murray added the comment:

Something like that.  That folding algorithm is a bit...bizantine.  I need to 
sit down and completely rewrite it, I think.  But maybe I can fix this problem 
in the meantime, until I have time to do that.

--
versions: +Python 3.5

___
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



[issue22684] message.as_bytes() produces recursion depth exceeded

2014-10-21 Thread Pas

New submission from Pas:

Please see the attached traceback (or this http://pastebin.com/WYinRGie for 
fancy colors).

It depends on message size, we're trying to send Multipart MIME messages (a PDF 
attached, that has an image embedded).

After editing flask_mail.py to use the fallback ( 
message().as_string().encode(self.charset or 'utf-8') ) things work again.

If anyone could help confirm if this is a bug, or help me understand how I 
misuse the library, I'd be grateful. Thanks!

--
components: email
files: py34-email.message.as_bytes-recursion-depth-exceeded.txt
messages: 229762
nosy: barry, pas, r.david.murray
priority: normal
severity: normal
status: open
title: message.as_bytes() produces recursion depth exceeded
type: behavior
versions: Python 3.4
Added file: 
http://bugs.python.org/file36988/py34-email.message.as_bytes-recursion-depth-exceeded.txt

___
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



[issue22684] message.as_bytes() produces recursion depth exceeded

2014-10-21 Thread R. David Murray

R. David Murray added the comment:

It looks like a bug, but I'm not sure why as_bytes would trigger it but not 
as_string.

Can you supply a copy of the message that fails?  The as_string version 
(assuming the content was all ascii) should be enough to reproduce the issue, 
since it appears to be happening in the header folding step.

--

___
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