[issue41206] behaviour change with EmailMessage.set_content

Karthikeyan Singaravelan report at bugs.python.org
Mon Jul 6 08:32:21 EDT 2020


Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:

There is a behavior change with my fix. 7bit is returned for Content-Transfer-Encoding before commit and skipping the heuristic if line is empty to avoid ValueError will return quoted-printable for Content-Transfer-Encoding. This is a behavior change even if the ValueError is fixed. I would like to confirm which is the correct behavior and to be documented appropriately.

Test Case in test_contentmanager.py : 

    def test_set_text_plain_empty_content_heuristics(self):
        m = self._make_message()
        content = ""
        raw_data_manager.set_content(m, content)
        self.assertEqual(str(m), textwrap.dedent("""\                             
            Content-Type: text/plain; charset="utf-8"                             
            Content-Transfer-Encoding: quoted-printable                           
                                                                                  
                                                                                  
            """))
        self.assertEqual(m.get_payload(decode=True).decode('utf-8'), "\n")
        self.assertEqual(m.get_content(), "\n")

----------
nosy: +maxking

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41206>
_______________________________________


More information about the Python-bugs-list mailing list