[issue43323] UnicodeEncodeError: surrogates not allowed when parsing invalid charset

Serhiy Storchaka report at bugs.python.org
Sun Mar 27 03:00:23 EDT 2022


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

Sorry, I was puzzled by the exception type and missed details in a long traceback (I have issues with reading large texts). Thank you for your detailed report.

The simple fix is to add UnicodeEncodeError to "except LookupError". But there may be other places where we can get a similar error. They should be fixed too.

Alternatively we can do something when we get an invalid charset from the parsed data. I am not the email package expert, so I do not know what would be better in that context.

----------
components: +Library (Lib)
versions: +Python 3.11 -Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43323>
_______________________________________


More information about the Python-bugs-list mailing list