summaryrefslogtreecommitdiffstats
path: root/Lib/test
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/test
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/test')
-rw-r--r--Lib/test/test_email/test__header_value_parser.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_email/test__header_value_parser.py b/Lib/test/test_email/test__header_value_parser.py
index 46d90b3..71168f3 100644
--- a/Lib/test/test_email/test__header_value_parser.py
+++ b/Lib/test/test_email/test__header_value_parser.py
@@ -2638,6 +2638,12 @@ class TestParser(TestParserMixin, TestEmailBase):
)
self.assertEqual(msg_id.token_type, 'msg-id')
+ def test_get_msg_id_invalid_expected_msg_id_not_found(self):
+ text = "Message-Id: 935-XPB-567:0:86089:180874:0:45327:9:90305:17843586-40@example.com"
+ msg_id = parser.parse_message_id(text)
+ self.assertDefectsEqual(msg_id.all_defects,
+ [errors.InvalidHeaderDefect])
+
def test_get_msg_id_no_angle_start(self):
with self.assertRaises(errors.HeaderParseError):
parser.get_msg_id("msgwithnoankle")