aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/email/_header_value_parser.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-04-30 13:17:23 +0300
committerGitHub <noreply@github.com>2022-04-30 13:17:23 +0300
commite91dee87edcf6dee5dd78053004d76e5f05456d4 (patch)
tree39267dc065a5ce04396423837df258e7c808056b /Lib/email/_header_value_parser.py
parent3483299a24e41a7f2e958369cb3573d7c2253e33 (diff)
downloadcpython-e91dee87edcf6dee5dd78053004d76e5f05456d4.tar.gz
cpython-e91dee87edcf6dee5dd78053004d76e5f05456d4.zip
bpo-43323: Fix UnicodeEncodeError in the email module (GH-32137)
It was raised if the charset itself contains characters not encodable in UTF-8 (in particular \udcxx characters representing non-decodable bytes in the source).
Diffstat (limited to 'Lib/email/_header_value_parser.py')
-rw-r--r--Lib/email/_header_value_parser.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index 51d355fbb0a..8a8fb8bc42a 100644
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -781,7 +781,7 @@ class MimeParameters(TokenList):
else:
try:
value = value.decode(charset, 'surrogateescape')
- except LookupError:
+ except (LookupError, UnicodeEncodeError):
# XXX: there should really be a custom defect for
# unknown character set to make it easy to find,
# because otherwise unknown charset is a silent