summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-12-05 03:14:26 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-12-05 03:14:26 (GMT)
commitbb815499af855b1759c02535f8d7a9d0358e74e8 (patch)
tree1ee1d5c2c5377e0a8ed71a9153af4c76b6824d6d /Lib/email
parent8b787964e0a647caa0558b7c29ae501470d727d9 (diff)
downloadcpython-bb815499af855b1759c02535f8d7a9d0358e74e8.zip
cpython-bb815499af855b1759c02535f8d7a9d0358e74e8.tar.gz
cpython-bb815499af855b1759c02535f8d7a9d0358e74e8.tar.bz2
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')
-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 1668b4a..abdef81 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
#