| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,14 +59,18 @@ def validate_email( | |||
| 59 | 59 | if timeout is None and dns_resolver is None: | |
| 60 | 60 | timeout = DEFAULT_TIMEOUT | |
| 61 | 61 | ||
| 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. | ||
| 66 | 68 | try: | |
| 67 | 69 | email = email.decode("ascii") | |
| 68 | 70 | except ValueError as e: | |
| 69 | 71 | raise EmailSyntaxError("The email address is not valid ASCII.") from e | |
| 72 | + else: | ||
| 73 | + raise TypeError("email must be str or bytes") | ||
| 70 | 74 | ||
| 71 | 75 | # Split the address into the display name (or None), the local part | |
| 72 | 76 | # (before the @-sign), and the domain part (after the @-sign). | |
| Back | FazBrowse Home | New Git URL |
0 commit comments