patch Django for Python 3.13 (#89506)
gitea/publik-devinst/pipeline/head This commit looks good Details

This commit is contained in:
Thomas NOËL 2024-04-12 21:21:41 +02:00
parent fc6364fb7f
commit af318c31ea
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,23 @@
commit b231bcd19e57267ce1fc21d42d46f0b65fdcfcf8
Author: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Date: Fri Mar 15 12:51:40 2024 +0100
Refs #34900 -- Fixed SafeMIMEText.set_payload() crash on Python 3.13.
Payloads with surrogates are passed to the set_payload() since
https://github.com/python/cpython/commit/f97f25ef5dfcdfec0d9a359fd970abd139cf3428
diff --git a/django/core/mail/message.py b/django/core/mail/message.py
index 4f8c93e9e5..205c680561 100644
--- a/django/core/mail/message.py
+++ b/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

View File

@ -21,6 +21,7 @@
- memcached
- nginx
- npm
- patch
- pkg-config
- postgresql
- python3-apt
@ -74,6 +75,9 @@
src: utils.py
dest: "{{venv_py3_site_packages}}/django/db/backends/postgresql/utils.py"
- name: patch django/core/mail/message.py
shell: "patch -p1 {{venv_py3_site_packages}}/django/core/mail/message.py roles/base/files/django-b231bcd19e57267ce1fc21d42d46f0b65fdcfcf8.patch"
- name: install django-debug-toolbar
pip:
name: "django-debug-toolbar<3"