Irit Katriel added the comment:
I am also unable to reproduce the issue on 3.11 with the attached script and
input.
Please create a new issue if this problem still exists in a current python
version (>= 3.9).
--
nosy: +iritkatriel
resolution: -> works for me
stage: -> resolved
sta
Pedro Lacerda added the comment:
Now the file is back! If any previous header has a newline before the value the
error will not happen. But even with the output correct it isn't as expected.
--
Added file: http://bugs.python.org/file43457/flatten-no-exception.mail
_
Pedro Lacerda added the comment:
Now the file is back! If any previous header has a newline before the value the
error will not happen. But even with the output correct it isn't as expected.
--
Added file: http://bugs.python.org/file43456/flatten-no-exception.mail
_
Pedro Lacerda added the comment:
Seems that ``token.has_fws`` evaluates to True in the following condition
if token.has_fws:
causing ``token._fold(self)`` where isn't needed and raising the exception.
Hope it helps!
By the way, why the _header_value_parser.py was removed from the reposito
Hans-Peter Jansen added the comment:
Sorry guys for not providing this earlier.
It turned out, that the sub optimal behaviour is related to a unfortunate
policy choice: email.policy.SMTP.
--
Added file: http://bugs.python.org/file43415/email_flatten.py
Berker Peksag added the comment:
Thanks for helping to triage this, Pedro. I think there is a typo in your
example: ``email.message_from_binary_file(fp)`` needs to be passed to
``bs.flatten()``.
With the following script I'm also unable to reproduce the issue in Python 3.4+:
import email
Pedro Lacerda added the comment:
I was unable to reproduce this bug using the following snippet
import email, sys
from email.generator import BytesGenerator
from email.mime.text import MIMEText
fp = open('flatten-exception.mail', 'rb')
email.message_from_binary_file(fp)
New submission from Hans-Peter Jansen:
Attached mail, parsed with email.message_from_binary_file results in:
Traceback (most recent call last):
File "./mail_filter.py", line 616, in
ret = main.run()
File "./mail_filter.py", line 605, in run
self.process(fp)
File "./mail_filter.py"