summaryrefslogtreecommitdiff
path: root/Lib/email/_header_value_parser.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-12-05 04:14:26 +0100
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-12-04 19:14:26 -0800
commitbb815499af855b1759c02535f8d7a9d0358e74e8 (patch)
tree1ee1d5c2c5377e0a8ed71a9153af4c76b6824d6d /Lib/email/_header_value_parser.py
parent8b787964e0a647caa0558b7c29ae501470d727d9 (diff)
downloadcpython-git-bb815499af855b1759c02535f8d7a9d0358e74e8.tar.gz
bpo-38698: Prevent UnboundLocalError to pop up in parse_message_id (GH-17277)
parse_message_id() was improperly using a token defined inside an exception handler, which was raising `UnboundLocalError` on parsing an invalid value. https://bugs.python.org/issue38698
Diffstat (limited to 'Lib/email/_header_value_parser.py')
-rw-r--r--Lib/email/_header_value_parser.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py
index 1668b4a14e..abdef8189c 100644
--- a/Lib/email/_header_value_parser.py
+++ b/Lib/email/_header_value_parser.py
@@ -2113,7 +2113,8 @@ def parse_message_id(value):
except errors.HeaderParseError:
message_id.defects.append(errors.InvalidHeaderDefect(
"Expected msg-id but found {!r}".format(value)))
- message_id.append(token)
+ else:
+ message_id.append(token)
return message_id
#