[3.9] bpo-27321 Fix email.generator.py to not replace a non-existent header. (GH-18074) by miss-islington · Pull Request #22796 · python/cpython (original) (raw)
This PR replaces GH-1977. The reason for the replacement is two-fold.
The fix itself is different is that if the CTE header doesn't exist in the original message, it is inserted. This is important because the new CTE could be quoted-printable whereas the original is implicit 8bit.
Also the tests are different. The test_nonascii_as_string_without_cte test in GH-1977 doesn't actually test the issue in that it passes without the fix. The test_nonascii_as_string_without_content_type_and_cte test is improved here, and even though it doesn't fail without the fix, it is included for completeness.
Automerge-Triggered-By: @warsaw
(cherry picked from commit bf83822)
Co-authored-by: Mark Sapiro mark@msapiro.net
https://bugs.python.org/issue27321
Automerge-Triggered-By: @warsaw