◐ Shell
clean mode source ↗

gh-81074: Allow non-ASCII addr_spec in email.headerregistry.Address by medmunds · Pull Request #122477 · python/cpython

The email.headerregistry.Address constructor raised an error if
addr_spec contained a non-ASCII character. (But it fully supports
non-ASCII in the separate username and domain args.) This change
removes the error for a non-ASCII addr_spec.

@blurb-it

The email.headerregistry.Address constructor raised an error if
addr_spec contained a non-ASCII character. (But it fully supports
non-ASCII in the separate username and domain args.) This change
removes the error for a non-ASCII addr_spec.

@34j 34j mentioned this pull request

Feb 22, 2025

6 tasks

bitdancer

When parsing email messages from Unicode strings (but not bytes),
get_local_part() recorded a NonASCIILocalPartDefect for non-ASCII
characters. RFC 5322 permits such addresses.

This change:
- removes the parse-time detection for a non-ASCII local-part
  (and a related test)
- adds tests for passing a non-ASCII addr_spec to
  email.headerregistry.Address.__init__()
- marks the (undocumented) email.errors.NonASCIILocalPartDefect
  as unused and deprecated

 This affected parsing email messages from Unicode strings
(but not from bytes), and also prevented

bitdancer