Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-81074: Allow non-ASCII addr_spec in email.headerregistry.Address #122477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

medmunds
Copy link
Contributor

@medmunds medmunds commented Jul 30, 2024

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.

This PR implements @bitdancer's suggested fix from #81074 (comment):

… But with RFC6532 support, it should be valid to have a local part that has non-ascii in an Address, and the error, as I noted above, should be raised only at serialization time and when we don't have an original source string. So that raise should be modified to explicitly ignore the NonASCIILocalPartDefect.

(The other bugs discussed in that comment are reported separately as #83938 and #122476.)

Fixes gh-81074

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.
@medmunds medmunds requested a review from a team as a code owner July 30, 2024 19:16
@ghost
Copy link

ghost commented Jul 30, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Jul 30, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

medmunds and others added 4 commits September 9, 2024 14:06
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.
@encukou
Copy link
Member

encukou commented Mar 19, 2025

@bitdancer, as the email expert, do you want to review this?

@bitdancer
Copy link
Member

Yes, I'll add it to my list. It will take me quite some time to get through the backlog, unfortunately.

@bedevere-app
Copy link

bedevere-app bot commented May 18, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

medmunds added 3 commits May 26, 2025 14:48
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
@medmunds
Copy link
Contributor Author

I have made the requested changes; please review again

@bedevere-app
Copy link

bedevere-app bot commented May 26, 2025

Thanks for making the requested changes!

@bitdancer: please review the changes made to this pull request.

@bedevere-app bedevere-app bot requested a review from bitdancer May 26, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

email.headerregistry.Address blocks Unicode local part addr_spec accepted elsewhere
5 participants