summaryrefslogtreecommitdiff
path: root/Lib/email
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/utils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/email/utils.py b/Lib/email/utils.py
index 93a625c8b4..f76c21eb1b 100644
--- a/Lib/email/utils.py
+++ b/Lib/email/utils.py
@@ -337,6 +337,10 @@ def collapse_rfc2231_value(value, errors='replace',
# object. We do not want bytes() normal utf-8 decoder, we want a straight
# interpretation of the string as character bytes.
charset, language, text = value
+ if charset is None:
+ # Issue 17369: if charset/lang is None, decode_rfc2231 couldn't parse
+ # the value, so use the fallback_charset.
+ charset = fallback_charset
rawbytes = bytes(text, 'raw-unicode-escape')
try:
return str(rawbytes, charset, errors)