Skip to content

Commit f86807e

Browse files
committed
Do not enforce ASCII only in get_local_part
1 parent ce7039d commit f86807e

3 files changed

Lines changed: 2 additions & 12 deletions

File tree

Lib/email/_header_value_parser.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,11 +1480,6 @@ def get_local_part(value):
14801480
local_part.defects.append(errors.ObsoleteHeaderDefect(
14811481
"local-part is not a dot-atom (contains CFWS)"))
14821482
local_part[0] = obs_local_part
1483-
try:
1484-
local_part.value.encode('ascii')
1485-
except UnicodeEncodeError:
1486-
local_part.defects.append(errors.NonASCIILocalPartDefect(
1487-
"local-part contains non-ASCII characters)"))
14881483
return local_part, value
14891484

14901485
def get_obs_local_part(value):

Lib/email/errors.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,5 @@ def __str__(self):
104104
class ObsoleteHeaderDefect(HeaderDefect):
105105
"""Header uses syntax declared obsolete by RFC 5322"""
106106

107-
class NonASCIILocalPartDefect(HeaderDefect):
108-
"""local_part contains non-ASCII characters"""
109-
# This defect only occurs during unicode parsing, not when
110-
# parsing messages decoded from binary.
111-
112107
class InvalidDateDefect(HeaderDefect):
113108
"""Header has unparsable or invalid date"""

Lib/test/test_email/test__header_value_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,14 +1214,14 @@ def test_get_local_part_valid_and_invalid_qp_in_atom_list(self):
12141214
'@example.com')
12151215
self.assertEqual(local_part.local_part, r'\example\\ example')
12161216

1217-
def test_get_local_part_unicode_defect(self):
1217+
def test_get_local_part_unicode(self):
12181218
# Currently this only happens when parsing unicode, not when parsing
12191219
# stuff that was originally binary.
12201220
local_part = self._test_get_x(parser.get_local_part,
12211221
'exámple@example.com',
12221222
'exámple',
12231223
'exámple',
1224-
[errors.NonASCIILocalPartDefect],
1224+
[],
12251225
'@example.com')
12261226
self.assertEqual(local_part.local_part, 'exámple')
12271227

0 commit comments

Comments
 (0)