﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34732	UnicodeEncodeError on two tests in Python 3.12	Michel Lind	nobody	"When running the tests inside a virtual environment with Fedora 39's python3-3.12.0~b4-1.fc39.x86_64, there are currently two test failures left with the `test_sqlite` backend


{{{
======================================================================
ERROR: test_safe_mime_multipart (mail.tests.MailTests.test_safe_mime_multipart)
Make sure headers can be set with a different encoding than utf-8 in
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 64, in forbid_multi_line_headers
    val.encode(""ascii"")                                           
UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 2: ordinal not in range(128)
                                                                                                                                    
During handling of the above exception, another exception occurred:
                                                                                                                                    
Traceback (most recent call last):                                                                                                  
  File ""/home/michel/src/github/django/django/tests/mail/tests.py"", line 504, in test_safe_mime_multipart
    msg.message()[""To""],
    ^^^^^^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 266, in message
    self._set_list_header_if_not_empty(msg, ""To"", self.to)
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 431, in _set_list_header_if_not_empty
    msg[header] = value
    ~~~^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 188, in __setitem__
    name, val = forbid_multi_line_headers(name, val, self.encoding)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 67, in forbid_multi_line_headers
    val = "", "".join(
          ^^^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 68, in <genexpr>
    sanitize_address(addr, encoding) for addr in getaddresses((val,))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 101, in sanitize_address
    raise ValueError(f'Invalid address ""{address}""')
ValueError: Invalid address """"

======================================================================
ERROR: test_unicode_address_header (mail.tests.MailTests.test_unicode_address_header)
Regression for #11144 - When a to/from/cc header contains Unicode, 
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 64, in forbid_multi_line_headers
    val.encode(""ascii"")
UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in position 2: ordinal not in range(128)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ""/home/michel/src/github/django/django/tests/mail/tests.py"", line 461, in test_unicode_address_header
    email.message()[""To""],
    ^^^^^^^^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 266, in message
    self._set_list_header_if_not_empty(msg, ""To"", self.to)
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 431, in _set_list_header_if_not_empty
    msg[header] = value
    ~~~^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 165, in __setitem__
    name, val = forbid_multi_line_headers(name, val, self.encoding)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 67, in forbid_multi_line_headers
    val = "", "".join(
          ^^^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 68, in <genexpr>
    sanitize_address(addr, encoding) for addr in getaddresses((val,))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ""/home/michel/src/github/django/django/django/core/mail/message.py"", line 101, in sanitize_address
    raise ValueError(f'Invalid address ""{address}""')
ValueError: Invalid address """"

}}}
"	Uncategorized	closed	Uncategorized	dev	Normal	invalid			Unreviewed	0	0	0	0	0	0
