Open
Description
I get this error on one of my ARM64 test machines.
The s.encode('ascii', 'surrogateescape')
looks strange to my eyes, since ASCII doesn't have a way to encode surrogates? I assume the handler has tried to do it (hence "position 6-8" not 6-7), but really this ought to just fail (perhaps explicitly) and email
shouldn't be passing ascii and surrogateescape together.
I'm not sure why it doesn't occur on other platforms. This really ought to be an error all the time - ideas?
test_basic (test.test_logging.SMTPHandlerTest.test_basic) ... --- Logging error ---
Traceback (most recent call last):
File "D:\agent\_work\3\b\layout\Lib\logging\handlers.py", line 1086, in emit
smtp.send_message(msg)
~~~~~~~~~~~~~~~~~^^^^^
File "D:\agent\_work\3\b\layout\Lib\smtplib.py", line 973, in send_message
g.flatten(msg_copy, linesep='\r\n')
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\agent\_work\3\b\layout\Lib\email\generator.py", line 115, in flatten
self._write(msg)
~~~~~~~~~~~^^^^^
File "D:\agent\_work\3\b\layout\Lib\email\generator.py", line 180, in _write
self._dispatch(msg)
~~~~~~~~~~~~~~^^^^^
File "D:\agent\_work\3\b\layout\Lib\email\generator.py", line 217, in _dispatch
meth(msg)
~~~~^^^^^
File "D:\agent\_work\3\b\layout\Lib\email\generator.py", line 433, in _handle_text
self._write_lines(msg._payload)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
File "D:\agent\_work\3\b\layout\Lib\email\generator.py", line 154, in _write_lines
self.write(line)
~~~~~~~~~~^^^^^^
File "D:\agent\_work\3\b\layout\Lib\email\generator.py", line 409, in write
self._fp.write(s.encode('ascii', 'surrogateescape'))
~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'ascii' codec can't encode characters in position 6-8: ordinal not in range(128)
[skip test infrastructure stack]
File "D:\agent\_work\3\b\layout\Lib\test\test_logging.py", line 1126, in test_basic
h.handle(r)
Message: 'Hello \u2713'
Arguments: ()
FAIL