Skip to content

Timeout on DNS resolution => KeyError #41

@GregoireDelannoy

Description

@GregoireDelannoy

Hello,

After upgrading to the latest version, I noticed a surprising behavior in case of resolution timeout:

>>> res = email_validator.validate_email('greg@domain.fr', check_deliverability = True, timeout=0.0000001)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/omnibook/lib/python3.6/site-packages/email_validator/__init__.py", line 266, in validate_email
    ret.mx = deliverability_info["mx"]
KeyError: 'mx'

As the function validate_email_deliverability() can return a dict containing the only key unknown-deliverability, the calling function raise a KeyError.

In a comment, you suggest not wanting to raise Exceptions in case of a timeout. I think it would be better to do it, but I agree not to make it children of EmailNotValidError. What's your take on the best way to do it?

All the best, and thanks for the lib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions