Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion email_validator/validate_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def validate_email(
ret.normalized = ret.local_part + "@" + ret.domain

# If the email address has an ASCII form, add it.
if ret.ascii_local_part and ret.ascii_domain:
if ret.ascii_local_part is not None and ret.ascii_domain:
ret.ascii_email = (ret.ascii_local_part or "") + "@" + ret.ascii_domain
else:
ret.ascii_email = None
Expand Down
5 changes: 5 additions & 0 deletions tests/test_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,11 @@ def test_email_invalid_character_smtputf8_off(email_input: str, expected_error:
def test_email_empty_local() -> None:
validate_email("@test", allow_empty_local=True, test_environment=True)

# An empty local part is ASCII, so the ASCII form of the address is set.
validated = validate_email("@example.com", allow_empty_local=True, check_deliverability=False)
assert validated.ascii_local_part == ""
assert validated.ascii_email == "@example.com"

# This next one might not be desirable.
validate_email("\"\"@test", allow_empty_local=True, allow_quoted_local=True, test_environment=True)

Expand Down
Loading