This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jpic
Recipients Dain Dwarf, Windson Yang, barry, bortzmeyer, cnicodeme, jpic, kal.sze, msapiro, ned.deily, nicoe, r.david.murray, vstinner, xtreak
Date 2019-05-04.13:02:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
In-reply-to <>
At is allowed in the local part if quoted, the proposed patch acts within
get_domain() and getdomain() and does not affect local part parsing. This
still works:

>>> parseaddr('"fo@bar"')
('', '"fo@bar"')

>>> email.message_from_string('From: "a@b"
(Address(display_name='', username='a@b', domain=''),)

I'm not against raising an exception in parseaddr, but you should know that
currently nothing in parseaddr seems to raise an exception:

jpic@ci:~/cpython$ grep raise Lib/email/

For example:

>>> parseaddr('aoeu')
('', 'aoeu')
>>> parseaddr('a@')
('', 'a@')

None of the above calls raised an exception. That is the reason why I did
not introduce a new Exception in the getdomain() change: I thought it would
be more consistent with the rest of the API as such.

As for the new API, the patch does raise a parse error:

 # this detect that the next caracter right after the parsed domain is
another @
if value and value[0] == '@':
      raise errors.HeaderParseError('Multiple domains')

But that's in the lower level API that is planned for going public later on
(probably when it will have unit tests), it's just the higher level API
that the user faces that swallows it. As a user you can still know about
that parse problem using the defects attribute:

>>> email.message_from_string('From:',
InvalidHeaderDefect('invalid address in address-list')
Date User Action Args
2019-05-04 13:02:09jpicsetrecipients: + jpic, barry, vstinner, msapiro, ned.deily, r.david.murray, nicoe, kal.sze, Windson Yang, xtreak, cnicodeme, bortzmeyer, Dain Dwarf
2019-05-04 13:02:09jpiclinkissue34155 messages
2019-05-04 13:02:08jpiccreate