Skip to content

Commit 0300001

Browse files
committed
Fix SafeMIMEText.set_payload() crash on Python 3.13
See django/django@b231bcd
1 parent e0605bb commit 0300001

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flask_mailman/message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def __setitem__(self, name, val):
159159

160160
def set_payload(self, payload, charset=None):
161161
if charset == 'utf-8' and not isinstance(charset, Charset.Charset):
162-
has_long_lines = any(len(line.encode()) > RFC5322_EMAIL_LINE_LENGTH_LIMIT for line in payload.splitlines())
162+
has_long_lines = any(len(line.encode(errors="surrogateescape")) > RFC5322_EMAIL_LINE_LENGTH_LIMIT for line in payload.splitlines())
163163
# Quoted-Printable encoding has the side effect of shortening long
164164
# lines, if any (#22561).
165165
charset = utf8_charset_qp if has_long_lines else utf8_charset

0 commit comments

Comments
 (0)