Bug report
Bug description:
Documented behaviour: Address.init docstring: "The addr_spec and the string value of the object are both quoted according to RFC5322 rules, but without any Content Transfer Encoding."
Expected: Address(username='.a', domain='example.com').addr_spec returns '".a"@example.com', which parses with username='.a' and domain='example.com'.
Actual: addr_spec returns '.a@example.com'; parsing it raises InvalidHeaderDefect.
import re
from email.headerregistry import Address
u, d = ".a", "example.com"
try:
if not re.fullmatch(r"[A-Za-z.]+", u) or d != "example.com":
raise ValueError("input is outside the documented test case")
# username is supplied unquoted, not as an addr_spec; dots are legal
# quoted-string content. Only dot-atoms may remain unquoted here.
local = u if re.fullmatch(r"[A-Za-z]+(?:\.[A-Za-z]+)*", u) else f'"{u}"'
expected = (local + "@" + d, u, d)
a = Address(username=u, domain=d)
if (a.username, a.domain) != (u, d):
raise ValueError("constructor did not accept the input unchanged")
s = a.addr_spec
try:
b = Address(addr_spec=s)
actual = (s, b.username, b.domain)
except Exception as e:
actual = (s, "parse error", type(e).__name__, str(e))
if actual != expected:
print("REFUTATION CONFIRMED:", (u, d), "actual:", actual, "expected:", expected)
else:
print("REFUTATION REJECTED: output is correctly quoted and round-trips")
except Exception as e:
print("REFUTATION REJECTED:", type(e).__name__, str(e))
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library email.headerregistry:
REFUTATION CONFIRMED: ('.a', 'example.com') actual: ('.a@example.com', 'parse error', 'InvalidHeaderDefect', 'local-part is not dot-atom, quoted-string, or obs-local-part') expected: ('".a"@example.com', '.a', 'example.com')
This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/email.headerregistry-20261003-021509-c1
CPython versions tested on:
3.14
Operating systems tested on:
Windows
Bug report
Bug description:
Documented behaviour: Address.init docstring: "The addr_spec and the string value of the object are both quoted according to RFC5322 rules, but without any Content Transfer Encoding."
Expected: Address(username='.a', domain='example.com').addr_spec returns '".a"@example.com', which parses with username='.a' and domain='example.com'.
Actual: addr_spec returns '.a@example.com'; parsing it raises InvalidHeaderDefect.
Output on Python 3.14.6 (Windows-11-10.0.26220-SP0), standard library
email.headerregistry:This report was found and written by an automated property-testing tool I run (bugforge). The reproducer above was executed and its output is pasted unedited; no person reviewed the report before it was filed. The search script is in https://github.com/augusto-rehfeldt/bugforge-results/tree/main/email.headerregistry-20261003-021509-c1
CPython versions tested on:
3.14
Operating systems tested on:
Windows