File fix-safemimetext-set_payload.patch of Package python-Django.36738

Index: Django-4.2.11/django/core/mail/message.py
===================================================================
--- Django-4.2.11.orig/django/core/mail/message.py
+++ Django-4.2.11/django/core/mail/message.py
@@ -168,7 +168,8 @@ class SafeMIMEText(MIMEMixin, MIMEText):
     def set_payload(self, payload, charset=None):
         if charset == "utf-8" and not isinstance(charset, Charset.Charset):
             has_long_lines = any(
-                len(line.encode()) > RFC5322_EMAIL_LINE_LENGTH_LIMIT
+                len(line.encode(errors="surrogateescape"))
+                > RFC5322_EMAIL_LINE_LENGTH_LIMIT
                 for line in payload.splitlines()
             )
             # Quoted-Printable encoding has the side effect of shortening long
openSUSE Build Service is sponsored by