File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -59,14 +59,18 @@ def validate_email(
5959 if timeout is None and dns_resolver is None :
6060 timeout = DEFAULT_TIMEOUT
6161
62- # Allow email to be a str or bytes instance. If bytes,
63- # it must be ASCII because that's how the bytes work
64- # on the wire with SMTP.
65- if not isinstance (email , str ):
62+ if isinstance (email , str ):
63+ pass
64+ elif isinstance (email , bytes ):
65+ # Allow email to be a bytes instance as if it is what
66+ # will be transmitted on the wire. But assume SMTPUTF8
67+ # is unavailable, so it must be ASCII.
6668 try :
6769 email = email .decode ("ascii" )
6870 except ValueError as e :
6971 raise EmailSyntaxError ("The email address is not valid ASCII." ) from e
72+ else :
73+ raise TypeError ("email must be str or bytes" )
7074
7175 # Split the address into the display name (or None), the local part
7276 # (before the @-sign), and the domain part (after the @-sign).
You can’t perform that action at this time.
0 commit comments