From 73970c8dda21c4df13373b03caede6273ff81e4c Mon Sep 17 00:00:00 2001 From: Kohaku-Blueleaf <59680068+KohakuBlueleaf@users.noreply.github.com> Date: Sat, 17 Oct 2026 20:18:32 +0800 Subject: [PATCH 1/2] Fix startswith_fws to check for non-empty list (gh-159621) Avoid access empty tokenlist reported in gh-159621 --- Lib/email/_header_value_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/email/_header_value_parser.py b/Lib/email/_header_value_parser.py index f396f4f9b32a9a8..9c1f99b1615f61c 100644 --- a/Lib/email/_header_value_parser.py +++ b/Lib/email/_header_value_parser.py @@ -155,7 +155,7 @@ def all_defects(self): return sum((x.all_defects for x in self), self.defects) def startswith_fws(self): - return self[0].startswith_fws() + return self and self[0].startswith_fws() as_ew_allowed = True From 136548f6ca49eee270572aa8c6271125ac2d4c66 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sun, 18 Oct 2026 05:47:57 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2026-10-18-05-47-56.gh-issue-159621.Uspw6i.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2026-10-18-05-47-56.gh-issue-159621.Uspw6i.rst diff --git a/Misc/NEWS.d/next/Library/2026-10-18-05-47-56.gh-issue-159621.Uspw6i.rst b/Misc/NEWS.d/next/Library/2026-10-18-05-47-56.gh-issue-159621.Uspw6i.rst new file mode 100644 index 000000000000000..e744bfe1b75579f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-18-05-47-56.gh-issue-159621.Uspw6i.rst @@ -0,0 +1,2 @@ +Fix an :exc:`IndexError` in :mod:`email` when folding address headers +containing empty comments.