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 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.