#35361: SafeMIMEText.set_payload() crash on Python 3.11.9
-------------------------------------------+------------------------
               Reporter:  Sarah Boyce      |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Core (Mail)      |        Version:  4.2
               Severity:  Release blocker  |       Keywords:
           Triage Stage:  Unreviewed       |      Has patch:  0
    Needs documentation:  0                |    Needs tests:  0
Patch needs improvement:  0                |  Easy pickings:  0
                  UI/UX:  0                |
-------------------------------------------+------------------------
 A recent bug fix to Python [https://github.com/python/cpython/issues/76511
 gh-76511] has been back ported to Python 3.11 and 3.12.
 See the release notes of
 [https://docs.python.org/release/3.11.9/whatsnew/changelog.html#python-3-11-9
 Python 3.11.9] and the soon to be released
 [https://docs.python.org/3/whatsnew/changelog.html Python 3.12.3].

 As part of the work to prepare Django for
 [https://code.djangoproject.com/ticket/34900 Python 3.13], a fix for this
 has already been merged to main in
 b231bcd19e57267ce1fc21d42d46f0b65fdcfcf8.

 Believe this needs to be back ported to Django 4.2 and Django 5.0 to
 support the latest (or soon to be latest) Python 3.11 and Python 3.12
 versions.

 Confirmed when testing Django 4.2 against Python 3.11.9, we know have the
 following test failure:

 {{{
 ======================================================================
 ERROR [0.034s]: test_dont_base64_encode
 (tests.mail.tests.MailTests.test_dont_base64_encode)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/tests/django/tests/mail/tests.py", line 902, in
 test_dont_base64_encode
     s = msg.message().as_string()
         ^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/tests/django/django/core/mail/message.py", line 133, in as_string
     g.flatten(self, unixfrom=unixfrom, linesep=linesep)
   File "/usr/local/lib/python3.11/email/generator.py", line 115, in
 flatten
     self._write(msg)
   File "/usr/local/lib/python3.11/email/generator.py", line 180, in _write
     self._dispatch(msg)
   File "/usr/local/lib/python3.11/email/generator.py", line 217, in
 _dispatch
     meth(msg)
   File "/usr/local/lib/python3.11/email/generator.py", line 246, in
 _handle_text
     msg.set_payload(msg._payload, charset)
   File "/tests/django/django/core/mail/message.py", line 168, in
 set_payload
     has_long_lines = any(
                      ^^^^
   File "/tests/django/django/core/mail/message.py", line 169, in <genexpr>
     len(line.encode()) > RFC5322_EMAIL_LINE_LENGTH_LIMIT
         ^^^^^^^^^^^^^
 UnicodeEncodeError: 'utf-8' codec can't encode characters in position
 28-33: surrogates not allowed

 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35361>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018ebdbeb580-9e1f95cf-2b4e-4f74-a195-967823e5c1df-000000%40eu-central-1.amazonses.com.

Reply via email to