GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-118716: Do not enforce ASCII to format address by cedk · Pull Request #118717 · python/cpython

Conversation

@cedk

@cedk cedk commented May 7, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

RFC 6530 allows UTF-8 strings

  • Issue: Support formatting UTF-8 email addresses #118716

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@cedk
cedk requested a review from a team as a code owner May 7, 2024 14:49
@bedevere-app bedevere-app Bot added the awaiting review label May 7, 2024
@bedevere-app bedevere-app Bot mentioned this pull request May 7, 2024
Support formatting UTF-8 email addresses #118716
Closed
@nineteendo

nineteendo commented May 7, 2024

Copy link
Copy Markdown
Contributor

You need to update this test:

cpython/Lib/test/test_email/test_email.py

Lines 3241 to 3245 in 26bab42

def test_unicode_address_raises_error(self):
# issue 1690608. email.utils.formataddr() should be rfc2047 aware.
addr = 'pers\u00f6[email protected]'
self.assertRaises(UnicodeError, utils.formataddr, (None, addr))
self.assertRaises(UnicodeError, utils.formataddr, ("Name", addr))

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nineteendo

nineteendo commented May 7, 2024

Copy link
Copy Markdown
Contributor

The commit that added this test pre-dates that rfc: 8debacb.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bitdancer

bitdancer commented May 7, 2024

Copy link
Copy Markdown
Member

IMO the legacy API (which is what you are modifying) should not support utf-8 addresses, since it provides no mechanisms for correctly interoperating with smtplib the way the new API does. Therefore I recommend rejecting this PR. See my comments on the issue for more.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nineteendo

nineteendo commented May 8, 2024

Copy link
Copy Markdown
Contributor

Could you add a news entry? https://blurb-it.herokuapp.com/add_blurb

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bitdancer
bitdancer requested changes May 9, 2024
View reviewed changes
Comment thread Lib/email/utils.py
"""
name, address = pair
# The address MUST (per RFC) be ascii, so raise a UnicodeError if it isn't.
address.encode('ascii')

@bitdancer bitdancer May 9, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I object to this change. I don't think the legacy API should be modified.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_email/test__header_value_parser.py Outdated
self.assertEqual(local_part.local_part, r'\example\\ example')

def test_get_local_part_unicode_defect(self):
def test_get_local_part_unicode(self):

@bitdancer bitdancer May 9, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not, IMO, the best solution. But fixing it right is non-trivial. The issue here is that this IS a defect if policy.utf8=False, and that should be maintained. The problem is that currently the header value parser does not have access to the policy. Which was a design mistake.

The reason you want to maintain the old behavior (aside from backward compatibility, which definitely counts) is that the parser is designed to be used in multiple scenarios, and one of those scenarios might be a place were we want to be emulating a non-SMTPUTF8 parser and looking at where a parsed message does not pass muster.

Now, that said, I'm not seeing any good way to fix this right. I think the best compromise might be to leave this defect alone, but to change the Address object so that it specifically ignores this defect (does not raise an error in that case). The smtp library should be raising an error if an attempt is made to actually send using a utf8 address to a server that does not support SMTPUTF8. With this compromise backward compatibility will be maintained, while still allowing utf8 addresses to be specified using Address (which should only be used by library consumers, not the library itself). I believe I am correct that such addresses will not otherwise be rejected by the email library.

This leaves a dangling issue that if we parse a message using utf8=True we technically should not get a defect, but unless and until we teach the header value parser about the policy we can't really fix that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting changes and removed awaiting review labels May 9, 2024
@bedevere-app

bedevere-app Bot commented May 9, 2024

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cedk
pythongh-118716: Do not fail on non ASCII local part when parsing add…
2bbb200
…r_spec

RFC 6530 allows UTF-8 strings in the local part.
@cedk
cedk force-pushed the email-utils-formataddr-utf-8 branch from ac72c64 to 2bbb200 Compare May 10, 2024 10:39
@blurb-it
📜🤖 Added by blurb_it.
0f62095
@cedk

cedk commented May 10, 2024

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added awaiting change review and removed awaiting changes labels May 10, 2024
@bedevere-app

bedevere-app Bot commented May 10, 2024

Copy link
Copy Markdown

Thanks for making the requested changes!

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app
bedevere-app Bot requested a review from bitdancer May 10, 2024 10:44
@github-actions

github-actions Bot commented Apr 16, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 16, 2026
@bitdancer

bitdancer commented Apr 18, 2026

Copy link
Copy Markdown
Member

I'm closing this because we are taking a different approach in #81074/#122477.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bitdancer bitdancer closed this Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bitdancer bitdancer Awaiting requested review from bitdancer

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting change review stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@cedk @nineteendo @bitdancer
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.