summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-12-05 17:42:01 (GMT)
committerGitHub <noreply@github.com>2019-12-05 17:42:01 (GMT)
commite21aa61e96f8343200e765d119ebe778873a6bf1 (patch)
treeb5349053ac33a268b72c02e802bf5d9032e93fda /Lib/email
parentcfdaf92221da3c264d0da9c588994fefe4073196 (diff)
downloadcpython-e21aa61e96f8343200e765d119ebe778873a6bf1.zip
cpython-e21aa61e96f8343200e765d119ebe778873a6bf1.tar.gz
cpython-e21aa61e96f8343200e765d119ebe778873a6bf1.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 (cherry picked from commit bb815499af855b1759c02535f8d7a9d0358e74e8) Co-authored-by: Claudiu Popa <pcmanticore@gmail.com>
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
#