Skip to content

Handle empty lists in strict email.utils.parseaddr #159350

Description

@esadomer

The strict path in email.utils.parseaddr() handles list input by reading its first item without checking for an empty list. The non-strict path returns an empty address pair for the same input.

Reproducer, run with the interpreter built from the CPython checkout:

from email.utils import parseaddr

print(parseaddr([], strict=False))
print(parseaddr([]))

Expected: Both calls return ('', '').

Observed: The default strict call raises IndexError.

Environment: CPython main, Windows debug build.

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-emailtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions