{{{
======================================================================
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 ""
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34732>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
This not an issue in Django, but a regression in Python 3.12.0b4, check
out https://github.com/python/cpython/issues/106669.
--
Ticket URL: <https://code.djangoproject.com/ticket/34732#comment:1>
Comment (by Michel Alexandre Salim):
Thanks! Yeah, I was just debugging with breakpoint() and realized it's
getaddresses that now returns `[('', '')]` as you noted
--
Ticket URL: <https://code.djangoproject.com/ticket/34732#comment:2>